|
| Path () |
| Default constructor for a zero-length path. More...
|
|
| Path (const std::string &path) |
| Implicit constructor from a string. More...
|
|
| Path (const char *path) |
| Implicit constructor from a c-style string. More...
|
|
| Path (const Path &path, const std::string &tail) |
| Constructor with an implicit pathAppend(). More...
|
|
| Path (const Path &path, const std::string &tail_1, const std::string &tail_2) |
| Constructor with two implicit pathAppend()s. More...
|
|
| Path (const Path &path, const std::string &tail_1, const std::string &tail_2, const std::string &tail_3) |
| Constructor with three implicit pathAppend()s. More...
|
|
| Path (std::initializer_list< std::string >) |
| Constructor with implicit pathAppend()s. More...
|
|
std::size_t | size () const noexcept |
| Returns the length of the path string. More...
|
|
bool | empty () const noexcept |
| Returns true if size() is zero. More...
|
|
std::string | str () const |
| Returns the path string. More...
|
|
const char * | cstr () const noexcept |
| Returns the path string. More...
|
|
bool | simple () const |
| Returns true if the path has a single component (ignoring "." parts), ie. More...
|
|
std::string | basename () const |
| Returns the rightmost part of the path, ignoring "." parts. More...
|
|
Path | dirname () const |
| Returns the path without the rightmost part, ignoring "." parts. More...
|
|
std::string | extension () const |
| Returns the path's basename extension, ie. More...
|
|
Path | withExtension (const std::string &ext) const |
| Returns the path with the new basename extension. More...
|
|
Path | withoutExtension () const |
| Returns a path without the basename extension, if any. More...
|
|
bool | isAbsolute () const |
| Returns !isRelative(). More...
|
|
bool | isRelative () const |
| Returns true if the path is a relative path or empty(). More...
|
|
void | pathAppend (const std::string &tail) |
| Appends a filename or a relative path to this path. More...
|
|
StringArray | split () const |
| Spits the path into a list of component parts (ignoring "." parts unless the whole path is "."). More...
|
|
Path | collapsed () const |
| Returns the path with "foo/.." and "." parts removed, so far as is possible without changing the meaning of the path. More...
|
|
void | swap (Path &other) noexcept |
| Swaps this with other. More...
|
|
bool | operator== (const Path &path) const |
| Comparison operator. More...
|
|
bool | operator!= (const Path &path) const |
| Comparison operator. More...
|
|
A Path object represents a file system path.
The class is concerned with path syntax, not file system i/o.
A full path is made up of a root, a set of directories, and a filename. The posix root is just a forward slash, but on Windows the root can be complex, possibly including non-splitting separator characters. The filename may have an extension part, which is to the right of the right-most dot.
The path separator is used between directories and filename, but only between the root and the first directory if the root does not itself end in a separator character.
A windows drive-letter root may end with a separator character or not; if there is no separator character at the end of the drive-letter root then the path is relative to the drive's current working directory.
Path components of "." are ignored by simple(), basename(), and dirname(). Path components of ".." are retained but can be eliminated if they are collapsed(). Path components of "." are eliminated by split(), except in the degenerate case.
This class is agnostic on the choice of UTF-8 or eight-bit characters since the delimiters are all seven-bit ascii.
Both posix and windows behaviours are available at run-time; the default behaviour is the native behaviour, but this can be overridden, typically for testing purposes.
The posix path separator character is the forward-slash; on Windows it is a back-slash, but with all forward-slashes converted to back-slashes immediately on input.
- See also
- G::File, G::Directory
Definition at line 71 of file gpath.h.