21 static constexpr
char SEPARATOR =
'/';
28 explicit Path(
const std::string& path);
78 std::string
native()
const;
139 friend std::ostream&
operator<<(std::ostream& stream,
const Path& path);
146 std::size_t findFolder(
const std::string& folder);
152 Path operator"" _path(
const char* nativePath,
const std::size_t size);
#define NAMESPACE_SPH_END
Object representing a path on a filesystem.
bool isRelative() const
Checks if the path is relative. Empty path is not considered relative.
Path operator/(const Path &other) const
Appends two paths together.
static Path currentPath()
Returns the current working directory, or empty path if the function failed.
Path & replaceExtension(const std::string &newExtension)
Changes the extension of the file.
Path & removeExtension()
Removes the extension from the path.
friend std::ostream & operator<<(std::ostream &stream, const Path &path)
Prints the path into the stream.
std::string native() const
Returns the native version of the path.
bool operator<(const Path &other) const
Does lexicographical comparison of two paths.
bool isRoot() const
Checks if the object holds root path.
Path & makeAbsolute()
Turns the path into an absolute path.
Path()=default
Constructs an empty path.
Path & removeSpecialDirs()
Removes . and .. directories from the path.
bool isHidden() const
Checks if the file is hidden, i.e. starts with a dot (makes only sense on Unit based systems).
bool empty() const
Checks if the path is empty.
Path & operator/=(const Path &other)
Appends another path to this one.
Path fileName() const
Returns the filename of the path.
Path parentPath() const
Returns the parent directory. If the path is empty or root, return empty path.
Path extension() const
Returns the extension of the filename.
bool operator==(const Path &other) const
Checks if two objects represent the same path.
bool hasExtension() const
Checks if the file has an extension.
bool operator!=(const Path &other) const
Checks if two objects represent different paths.
Path & makeRelative()
Turns the path into a relative path.