Represents a posix or windows file system path. More...
#include <Path.h>
Classes | |
struct | ParsedView |
Holds the various parsed components of a path. More... | |
struct | Posix |
struct | Windows |
Public Types | |
enum | Type { AsPosix , AsWindows , AsNative = AsPosix } |
Path type (windows or posix) More... | |
Static Public Member Functions | |
static bool | join (String &output, Span< const StringView > inputs, StringView separator=SeparatorStringView(), bool skipEmpty=false) |
Joins multiple StringView with a Separator into an output String. More... | |
static bool | parseNameExtension (const StringView input, StringView &name, StringView &extension) |
Splits a StringView of type "name.ext" into "name" and "ext". More... | |
static bool | parse (StringView input, Path::ParsedView &pathView, Type type) |
Splits a Posix or Windows path into a ParsedView. More... | |
static StringView | dirname (StringView input, Type type, int repeat=0) |
Returns the directory name of a path. More... | |
static StringView | basename (StringView input, Type type) |
Returns the base name of a path. More... | |
static StringView | basename (StringView input, StringView suffix) |
Returns the base name of a path. More... | |
static bool | isAbsolute (StringView input, Type type) |
Checks if a path is absolute. More... | |
static constexpr StringView | SeparatorStringView () |
Path separator StringView for current platform. More... | |
static bool | normalize (StringView view, Vector< StringView > &components, String *output, Type type) |
Resolves all .. to output a normalized path String. More... | |
static bool | relativeFromTo (StringView source, StringView destination, String &output, Type type, Type outputType=AsNative) |
Get relative path that appended to source resolves to destination . More... | |
static bool | append (String &output, Span< const StringView > paths, Type inputType) |
Append to an existing path a series of StringView with a separator. More... | |
static bool | endsWithSeparator (StringView path) |
Check if the path ends with a Windows or Posix separator. More... | |
static StringView | removeStartingSeparator (StringView path) |
Return a path without its (potential) starting separator. More... | |
static bool | normalizeUNCAndTrimQuotes (StringView fileLocation, Vector< StringView > &components, String &outputPath, Type type) |
Static Public Attributes | |
static constexpr char | Separator = '/' |
Path separator char for current platform. More... | |
Represents a posix or windows file system path.
enum SC::Path::Type |
Path type (windows or posix)
|
static |
Append to an existing path a series of StringView with a separator.
[out] | output | The destination string containing the existing path, that will be extended |
[in] | paths | The path components to join, appended to output |
[in] | inputType | Specify to append as Windows or Posix path components |
true
if the output
path can joined properly
|
static |
Returns the base name of a path.
Suffix is stripped if existing. Trailing separators are ignored.
For example:
[in] | input | The StringView with path to be parsed. Trailing separators are ignored. |
[in] | suffix | The StringView extension (or suffix in general) to strip if existing. |
input
holding the base name
|
static |
Returns the base name of a path.
Trailing separators are ignored.
For example:
[in] | input | The StringView with path to be parsed. Trailing separators are ignored. |
[in] | type | Specify to parse as Windows or Posix path |
input
holding the base name
|
static |
Returns the directory name of a path.
Trailing separators are ignored.
For example:
[in] | input | The StringView with path to be parsed. Trailing separators are ignored. |
[in] | type | Specify to parse as Windows or Posix path |
repeat | how many directory levels should be removed dirname("/1/2/3/4", repeat=1) == "/1/2" |
input
holding the directory name
|
static |
|
static |
Checks if a path is absolute.
For example:
[in] | input | The StringView with path to be parsed. Trailing separators are ignored. |
[in] | type | Specify to parse as Windows or Posix path |
true
if input
is absolute
|
static |
Joins multiple StringView with a Separator into an output String.
[out] | output | The output string receiving the path |
[in] | inputs | The input paths to join |
[in] | separator | The separator to use. By default / on Posix and \ on Windows |
[in] | skipEmpty | If true will skip empty entries in inputs Span |
|
static |
Resolves all ..
to output a normalized path String.
For example:
view | The path to be normalized (but it should not be a view() of the output String) | |
components | The parsed components that once joined will provide the normalized string | |
[out] | output | (Optional) pointer to String that will receive the normalized Path (if nullptr ) |
[in] | type | Specify to parse as Windows or Posix path |
true
if the Path was successfully parsed and normalized
|
static |
Splits a Posix or Windows path into a ParsedView.
[in] | input | The StringView with path to be parsed |
[out] | pathView | The output parsed ParsedView with all components of path |
[in] | type | Specify to parse as Windows or Posix path |
true
if path was parsed successfully
|
static |
Splits a StringView of type "name.ext" into "name" and "ext".
[in] | input | An input path coded as UTF8 sequence (ex. "name.ext") |
[out] | name | Output string holding name ("name" in "name.ext") |
[out] | extension | Output string holding extension ("ext" in "name.ext") |
false
if both name and extension will be empty after trying to parse themExample:
|
static |
Get relative path that appended to source
resolves to destination
.
For example:
[in] | source | The source Path |
[in] | destination | The destination Path |
[out] | output | The output relative path computed that transforms source into destination |
[in] | type | Specify to parse as Windows or Posix path |
[in] | outputType | Specify if the output relative path should be formatted as a Posix or Windows path |
true
if source and destination paths can be properly parsed as absolute paths
|
static |
Return a path without its (potential) starting separator.
path | The path to use |
|
inlinestaticconstexpr |
Path separator StringView for current platform.
|
staticconstexpr |
Path separator char for current platform.