10 namespace fs = std::filesystem;
35 explicit CPath(fs::path i_oPath) : m_oPath(std::move(i_oPath)) {}
53 this->m_oPath = std::move(i_oPath);
60 return this->m_oPath.replace_filename(i_oFilename);
67 return this->m_oPath.replace_extension(i_oExtension);
74 return this->m_oPath.root_name();
80 return this->m_oPath.root_path();
86 return this->m_oPath.relative_path();
92 return this->m_oPath.parent_path();
98 return this->m_oPath.stem();
104 return this->m_oPath.extension();
110 return fs::canonical(this->m_oPath);
116 return this->m_oPath.remove_filename();
121 [[nodiscard]]
const fs::path &
getPath()
const {
122 return this->m_oPath;
129 return this->m_oPath.generic_string();
135 return this->m_oPath.wstring();
142 return this->m_oPath.has_root_name();
148 return this->m_oPath.has_root_directory();
154 return this->m_oPath.has_relative_path();
160 return this->m_oPath.has_parent_path();
166 return this->m_oPath.has_filename();
172 return this->m_oPath.has_stem();
178 return this->m_oPath.has_extension();
184 return this->m_oPath.is_absolute();
190 return this->m_oPath.is_relative();
197 return this->m_oPath.begin();
203 return this->m_oPath.end();
218 this->m_oPath = std::move(i_oPath);
226 this->m_oPath.operator=(i_oPath.m_oPath);
234 this->m_oPath = std::move(i_oPath.m_oPath);
242 this->m_oPath.operator+=(i_oPath);
257 static bool exists(
const fs::path &i_oPath) {
258 return fs::exists(i_oPath);
A class that encapsulates the functionality of std::filesystem::path.
Definition: Path.h:28
fs::path getRelativePath() const
Returns the relative path.
Definition: Path.h:85
fs::path removeFilename()
Removes the filename from the path.
Definition: Path.h:115
auto begin()
Returns an iterator to the beginning of the path.
Definition: Path.h:196
bool hasFileNameWithoutExtension() const
Checks if the path has a filename without extension.
Definition: Path.h:171
fs::path getRootName() const
Returns the root name of the path.
Definition: Path.h:73
CPath & operator=(const CPath &i_oPath)
Assigns a new path to the object.
Definition: Path.h:225
static bool exists(const fs::path &i_oPath)
Checks whether a path exists.
Definition: Path.h:257
fs::path getAbsolutePath() const
Returns the absolute path.
Definition: Path.h:109
bool hasRootName() const
Checks if the path has a root name.
Definition: Path.h:141
bool exists() const
Checks whether the path exists.
Definition: Path.h:209
fs::path replaceExtension(const fs::path &i_oExtension)
Replaces the extension in the path.
Definition: Path.h:66
std::string toStdString() const
Converts the path to a standard string.
Definition: Path.h:128
CPath()=default
Default constructor.
fs::path getParentPath() const
Returns the parent path.
Definition: Path.h:91
CPath & operator+=(const fs::path &i_oPath)
Appends a path to the current path.
Definition: Path.h:241
CPath(const CPath &i_oPath)
Copy constructor.
Definition: Path.h:39
fs::path getFileNameWithoutExtension() const
Returns the filename without extension.
Definition: Path.h:97
bool hasFilename() const
Checks if the path has a filename.
Definition: Path.h:165
fs::path getRootPath() const
Returns the root directory of the path.
Definition: Path.h:79
CPath(CPath &&i_oPath) noexcept
Move constructor.
Definition: Path.h:43
CPath & operator=(fs::path i_oPath)
Assigns a new path to the object.
Definition: Path.h:217
bool hasExtension() const
Checks if the path has an extension.
Definition: Path.h:177
CPath & operator+=(const CPath &i_oPath)
Appends a path to the current path.
Definition: Path.h:249
fs::path replaceFilename(const fs::path &i_oFilename)
Replaces the filename in the path.
Definition: Path.h:59
fs::path getFileExtension() const
Returns the file extension.
Definition: Path.h:103
bool isRelativePath() const
Checks if the path is relative.
Definition: Path.h:189
bool hasRelativePath() const
Checks if the path has a relative path.
Definition: Path.h:153
bool hasRootDirectory() const
Checks if the path has a root directory.
Definition: Path.h:147
bool isAbsolutePath() const
Checks if the path is absolute.
Definition: Path.h:183
void setPath(fs::path i_oPath)
Sets the path.
Definition: Path.h:52
auto end()
Returns an iterator to the end of the path.
Definition: Path.h:202
CPath(fs::path i_oPath)
Construct from a std::filesystem::path.
Definition: Path.h:35
const fs::path & getPath() const
Returns the encapsulated fs::path object.
Definition: Path.h:121
CPath & operator=(CPath &&i_oPath)
Assigns a new path to the object.
Definition: Path.h:233
std::wstring toStdWString() const
Converts the path to a standard wide string.
Definition: Path.h:134
bool hasParentPath() const
Checks if the path has a parent path.
Definition: Path.h:159
The namespace encapsulating I/O related classes and functions in the Devel framework.