48 FilePath(
const std::filesystem::path &path) : _path(path) { }
63 return _path.filename().string();
71 return _path.stem().string();
79 auto ext = _path.extension().string();
91 auto fn = _path.filename().string();
92 auto pos =
fn.find(
'.');
93 if(pos == std::string::npos || pos == 0)
return String();
94 return fn.substr(pos + 1);
102 return FilePath(_path.parent_path());
147 return std::filesystem::exists(_path,
ec);
155 return _path.is_absolute();
163 return _path.is_relative();
172 return FilePath(std::filesystem::absolute(_path,
ec));
180 return _path.string();
193 return _path ==
other._path;
198 return _path !=
other._path;
203 return _path <
other._path;
207 std::filesystem::path _path;
Simple value type wrapping std::filesystem::path.
Definition filepath.h:27
FilePath(const String &path)
Constructs a FilePath from a String.
Definition filepath.h:36
FilePath(const std::filesystem::path &path)
Constructs a FilePath from a std::filesystem::path.
Definition filepath.h:48
FilePath operator/(const String &other) const
Joins this path with a string path component.
Definition filepath.h:128
FilePath join(const FilePath &other) const
Joins this path with another path component.
Definition filepath.h:110
bool isAbsolute() const
Returns true if the path is absolute.
Definition filepath.h:154
FilePath operator/(const char *other) const
Joins this path with a C string path component.
Definition filepath.h:137
FilePath()=default
Constructs an empty file path.
bool operator!=(const FilePath &other) const
Inequality comparison.
Definition filepath.h:197
String toString() const
Converts the path to a String.
Definition filepath.h:179
bool exists() const
Returns true if the path exists on the filesystem.
Definition filepath.h:145
bool isEmpty() const
Returns true if the path is empty.
Definition filepath.h:54
String fileName() const
Returns the filename component (including extension).
Definition filepath.h:62
String completeSuffix() const
Returns the complete suffix (all extensions).
Definition filepath.h:90
String suffix() const
Returns the file extension without the leading dot.
Definition filepath.h:78
FilePath(const char *path)
Constructs a FilePath from a C string.
Definition filepath.h:42
bool isRelative() const
Returns true if the path is relative.
Definition filepath.h:162
FilePath operator/(const FilePath &other) const
Joins this path with another path component.
Definition filepath.h:119
FilePath absolutePath() const
Returns the absolute form of this path.
Definition filepath.h:170
bool operator<(const FilePath &other) const
Less-than comparison for ordered containers.
Definition filepath.h:202
String baseName() const
Returns the filename without its extension.
Definition filepath.h:70
const std::filesystem::path & toStdPath() const
Returns the underlying std::filesystem::path.
Definition filepath.h:187
bool operator==(const FilePath &other) const
Equality comparison.
Definition filepath.h:192
FilePath parent() const
Returns the parent directory as a FilePath.
Definition filepath.h:101
Dynamic array container wrapping std::vector.
Definition list.h:40
size_t size() const noexcept
Returns the number of elements in the list.
Definition list.h:301
Encoding-aware string class with copy-on-write semantics.
Definition string.h:35
#define PROMEKI_NAMESPACE_BEGIN
Starts a promeki namespace block.
Definition namespace.h:14
#define PROMEKI_NAMESPACE_END
Ends a promeki namespace block.
Definition namespace.h:19