Class path
Defined in File filesystem_helper.hpp
Class Documentation
-
class path
Drop-in replacement for std::filesystem::path.
It must conform to the same standard described and cannot include methods that are not incorporated there.
Public Functions
-
path() = default
Constructs an empty path.
-
path(const std::string &p)
Conversion constructor from a std::string path.
- Parameters:
p – [in] A string path split by the platform’s string path separator.
-
path &operator=(const path&) = default
Copy assignment operator.
- Returns:
Reference to the copied path.
-
std::string string() const
Get the path delimited using this system’s path separator.
- Returns:
The path as a string
-
bool exists() const
Check if this path exists.
- Returns:
True if the path exists, false otherwise.
-
bool is_directory() const noexcept
Check if the path exists and it is a directory.
- Returns:
True if the path is an existing directory, false otherwise.
-
bool is_regular_file() const noexcept
Check if the path is a regular file.
- Returns:
True if the file is an existing regular file, false otherwise.
-
uint64_t file_size() const
Return the size of the file in bytes.
- Throws:
std::system_error –
- Returns:
size of file in bytes
-
bool empty() const
Check if the path is empty.
- Returns:
True if the path is empty, false otherwise.
-
bool is_absolute() const
Check if the path is an absolute path.
- Returns:
True if the path is absolute, false otherwise.
-
std::vector<std::string>::const_iterator cbegin() const
Const iterator to first element of this path.
- Returns:
A const iterator to the first element.
-
std::vector<std::string>::const_iterator cend() const
Const iterator to one past the last element of this path.
return A const iterator to one past the last element of the path.
-
path parent_path() const
Get the parent directory of this path.
- Returns:
A path to the parent directory.
-
path filename() const
Get the last element in this path.
If this path points to a directory, it will return the directory name.
- Returns:
The last element in this path
-
path extension() const
Get a relative path to the component including and following the last ‘.’.
- Returns:
The string extension
-
path operator/(const std::string &other) const
Concatenate a path and a string into a single path.
- Parameters:
other – [in] the string compnoent to concatenate
- Returns:
The combined path of this and other.
-
path &operator/=(const std::string &other)
Append a string component to this path.
- Parameters:
other – [in] the string component to append
- Returns:
*this
-
path() = default