|
xlnt - community edition
|
Encapsulates a path that points to location in a filesystem. More...
#include <path.hpp>
Public Member Functions | |
| path () | |
| Construct an empty path. More... | |
| path (const std::string &path_string) | |
| Counstruct a path from a string representing the path. More... | |
| path (const std::string &path_string, char sep) | |
| Construct a path from a string with an explicit directory seprator. More... | |
| bool | is_relative () const |
| Return true iff this path doesn't begin with / (or a drive letter on Windows). More... | |
| bool | is_absolute () const |
| Return true iff path::is_relative() is false. More... | |
| bool | is_root () const |
| Return true iff this path is the root directory. More... | |
| path | parent () const |
| Return a new path that points to the directory containing the current path, preserving its absolute root when present. Return the path unchanged if this path is the absolute or relative root. More... | |
| std::string | filename () const |
| Return the last component of this path. More... | |
| std::string | extension () const |
| Return the part of the path following the last dot in the filename. More... | |
| std::pair< std::string, std::string > | split_extension () const |
| Return a pair of strings resulting from splitting the filename on the last dot. More... | |
| std::vector< std::string > | split () const |
| Create a string representing this path separated by the provided separator or the system-default separator if not provided. More... | |
| const std::string & | string () const |
| Create a string representing this path separated by the provided separator or the system-default separator if not provided. More... | |
| path | resolve (const path &base_path) const |
| If this path is relative, append each component of this path to base_path and return the resulting absolute path. Otherwise, the the current path will be returned and base_path will be ignored. More... | |
| path | relative_to (const path &base_path) const |
| The inverse of path::resolve. Creates a path relative to the directory represented by base_path, including parent components where necessary. If the current path is already relative, or the paths have incompatible roots, return the current path unchanged. More... | |
| bool | exists () const |
| Return true iff the file or directory pointed to by this path exists on the filesystem. More... | |
| bool | is_directory () const |
| Return true if the file or directory pointed to by this path is a directory. More... | |
| bool | is_file () const |
| Return true if the file or directory pointed to by this path is a regular file. More... | |
| std::string | read_contents () const |
| Open the file pointed to by this path and return a string containing the files contents. More... | |
| path | append (const std::string &to_append) const |
| Append the provided part to this path and return the result. More... | |
| path | append (const path &to_append) const |
| Append the provided part to this path and return the result. More... | |
| bool | operator== (const path &other) const |
| Returns true if left path is equal to right path. More... | |
| bool | operator!= (const path &other) const |
| Returns true if left path is equal to right path. More... | |
Static Public Member Functions | |
| static char | system_separator () |
| The system-specific path separator character (e.g. '/' or '\'). More... | |
Encapsulates a path that points to location in a filesystem.
| xlnt::path::path | ( | ) |
Construct an empty path.
|
explicit |
Counstruct a path from a string representing the path.
| xlnt::path::path | ( | const std::string & | path_string, |
| char | sep | ||
| ) |
Construct a path from a string with an explicit directory seprator.
| path xlnt::path::append | ( | const std::string & | to_append | ) | const |
Append the provided part to this path and return the result.
Append the provided part to this path and return the result.
| bool xlnt::path::exists | ( | ) | const |
Return true iff the file or directory pointed to by this path exists on the filesystem.
| std::string xlnt::path::extension | ( | ) | const |
Return the part of the path following the last dot in the filename.
| std::string xlnt::path::filename | ( | ) | const |
Return the last component of this path.
| bool xlnt::path::is_absolute | ( | ) | const |
Return true iff path::is_relative() is false.
| bool xlnt::path::is_directory | ( | ) | const |
Return true if the file or directory pointed to by this path is a directory.
| bool xlnt::path::is_file | ( | ) | const |
Return true if the file or directory pointed to by this path is a regular file.
| bool xlnt::path::is_relative | ( | ) | const |
Return true iff this path doesn't begin with / (or a drive letter on Windows).
| bool xlnt::path::is_root | ( | ) | const |
Return true iff this path is the root directory.
| bool xlnt::path::operator!= | ( | const path & | other | ) | const |
Returns true if left path is equal to right path.
| bool xlnt::path::operator== | ( | const path & | other | ) | const |
Returns true if left path is equal to right path.
| path xlnt::path::parent | ( | ) | const |
Return a new path that points to the directory containing the current path, preserving its absolute root when present. Return the path unchanged if this path is the absolute or relative root.
| std::string xlnt::path::read_contents | ( | ) | const |
Open the file pointed to by this path and return a string containing the files contents.
The inverse of path::resolve. Creates a path relative to the directory represented by base_path, including parent components where necessary. If the current path is already relative, or the paths have incompatible roots, return the current path unchanged.
If this path is relative, append each component of this path to base_path and return the resulting absolute path. Otherwise, the the current path will be returned and base_path will be ignored.
| std::vector<std::string> xlnt::path::split | ( | ) | const |
Create a string representing this path separated by the provided separator or the system-default separator if not provided.
| std::pair<std::string, std::string> xlnt::path::split_extension | ( | ) | const |
Return a pair of strings resulting from splitting the filename on the last dot.
| const std::string& xlnt::path::string | ( | ) | const |
Create a string representing this path separated by the provided separator or the system-default separator if not provided.
|
static |
The system-specific path separator character (e.g. '/' or '\').
1.8.13