SPH
|
Object representing a path on a filesystem. More...
#include <Path.h>
Public Member Functions | |
Path ()=default | |
Constructs an empty path. More... | |
Path (const std::string &path) | |
Constructs a path from string. More... | |
bool | empty () const |
Checks if the path is empty. More... | |
bool | isHidden () const |
Checks if the file is hidden, i.e. starts with a dot (makes only sense on Unit based systems). More... | |
bool | isAbsolute () const |
bool | isRelative () const |
Checks if the path is relative. Empty path is not considered relative. More... | |
bool | isRoot () const |
Checks if the object holds root path. More... | |
bool | hasExtension () const |
Checks if the file has an extension. More... | |
Path | parentPath () const |
Returns the parent directory. If the path is empty or root, return empty path. More... | |
Path | fileName () const |
Returns the filename of the path. More... | |
Path | extension () const |
Returns the extension of the filename. More... | |
std::string | native () const |
Returns the native version of the path. More... | |
Path & | replaceExtension (const std::string &newExtension) |
Changes the extension of the file. More... | |
Path & | removeExtension () |
Removes the extension from the path. More... | |
Path & | removeSpecialDirs () |
Removes . and .. directories from the path. More... | |
Path & | makeAbsolute () |
Turns the path into an absolute path. More... | |
Path & | makeRelative () |
Turns the path into a relative path. More... | |
Path | operator/ (const Path &other) const |
Appends two paths together. More... | |
Path & | operator/= (const Path &other) |
Appends another path to this one. More... | |
bool | operator== (const Path &other) const |
Checks if two objects represent the same path. More... | |
bool | operator!= (const Path &other) const |
Checks if two objects represent different paths. More... | |
bool | operator< (const Path &other) const |
Does lexicographical comparison of two paths. More... | |
Static Public Member Functions | |
static Path | currentPath () |
Returns the current working directory, or empty path if the function failed. More... | |
Friends | |
std::ostream & | operator<< (std::ostream &stream, const Path &path) |
Prints the path into the stream. More... | |
Object representing a path on a filesystem.
Can represent both directory and file paths. Object does not check existence or accesibility of the path in any way, only syntactic aspects of the path are considered.
|
default |
Constructs an empty path.
|
explicit |
|
static |
Path Path::extension | ( | ) | const |
Path Path::fileName | ( | ) | const |
bool Path::hasExtension | ( | ) | const |
bool Path::isAbsolute | ( | ) | const |
bool Path::isHidden | ( | ) | const |
bool Path::isRelative | ( | ) | const |
bool Path::isRoot | ( | ) | const |
Path & Path::makeAbsolute | ( | ) |
Path & Path::makeRelative | ( | ) |
std::string Path::native | ( | ) | const |
bool Path::operator!= | ( | const Path & | other | ) | const |
bool Path::operator< | ( | const Path & | other | ) | const |
bool Path::operator== | ( | const Path & | other | ) | const |
Path Path::parentPath | ( | ) | const |
Path & Path::removeExtension | ( | ) |
Path & Path::removeSpecialDirs | ( | ) |
Path & Path::replaceExtension | ( | const std::string & | newExtension | ) |
Changes the extension of the file.
If the file has no extension, adds the given extension. For files with more than one extensions (.tar.gz, etc.), removes all extensions and adds the new one. If the new extension is empty, it behaves as removeExtension function.
|
friend |