![]() |
cppfs
1.2.0.5b71c2c98fb9
Cross-platform C++ file system library supporting multiple backends (Local-FS, SSH)
|
Path to file or directory. More...
#include <cppfs/include/cppfs/FilePath.h>
Public Member Functions | |
| FilePath () | |
| Constructor. More... | |
| FilePath (const FilePath &filePath) | |
| Copy constructor. More... | |
| FilePath (FilePath &&filePath) | |
| Move constructor. More... | |
| FilePath (const std::string &path) | |
| Constructor. More... | |
| FilePath (std::string &&path) | |
| Constructor. More... | |
| FilePath (const char *path) | |
| Constructor. More... | |
| virtual | ~FilePath () |
| Destructor. More... | |
| FilePath & | operator= (const FilePath &filePath) |
| Copy assignment operator. More... | |
| FilePath & | operator= (FilePath &&filePath) |
| Move assignment operator. More... | |
| const std::string & | path () const |
| Get path as string. More... | |
| void | setPath (const std::string &path) |
| Set path. More... | |
| void | setPath (std::string &&path) |
| Set path. More... | |
| std::string | toNative () const |
| Get native path as string. More... | |
| bool | isEmpty () const |
| Check if path is empty. More... | |
| bool | pointsToContent () const |
| Check if path points to the contents of a directory or container. More... | |
| const std::string & | fullPath () const |
| Get full path. More... | |
| const std::string & | fileName () const |
| Get file name. More... | |
| const std::string & | baseName () const |
| Get base name. More... | |
| const std::string & | extension () const |
| Get file extension. More... | |
| const std::string & | directoryPath () const |
| Get directory path. More... | |
| const std::string & | driveLetter () const |
| Get drive letter. More... | |
| bool | isAbsolute () const |
| Check if path is absolute. More... | |
| bool | isRelative () const |
| Check if path is relative. More... | |
| FilePath | resolve (const FilePath &path) const |
| Resolve relative path from this path. More... | |
| std::string | resolved () const |
| Resolve path (removed '.' and '..' entries if possible) More... | |
Protected Member Functions | |
| void | analyze () const |
| Analyze path and fill in the additional information. More... | |
Protected Attributes | |
| std::string | m_path |
| Path (unified format) More... | |
| bool | m_pointsToContent |
| 'true' if the path has a trailing separator, else 'false' More... | |
| bool | m_details |
| 'true' if path details have been analyzed, else 'false' More... | |
| std::string | m_fullPath |
| Full path (without trailing separators) More... | |
| std::string | m_filename |
| Filename component. More... | |
| std::string | m_basename |
| Basename component. More... | |
| std::string | m_extension |
| Extension component. More... | |
| std::string | m_directoryPath |
| Path to containing directory. More... | |
| std::string | m_driveLetter |
| Drive letter component. More... | |
| bool | m_absolute |
| 'true' if path is absolute, else 'false' More... | |
Path to file or directory.
This class stores a path to a file or directory and provides common operations like getting the file name or extension.
FilePath uses a unified format for storing paths that can be used consistently on every platform, using only '/' as a separator. When a FilePath is constructed from a string, the path is translated into the unified format and can then be used in a cross-platform way throughout an application. All operations on FilePath also return paths in the same unified format. To obtain a path in native platform format, use toNative().
All operations are completely string-based and don't use any system information. Therefore, paths are treated purely syntactically and do not imply that for example a file does really exist.
| cppfs::FilePath::FilePath | ( | ) |
Constructor.
| cppfs::FilePath::FilePath | ( | const FilePath & | filePath | ) |
Copy constructor.
| [in] | filePath | File path to copy |
| cppfs::FilePath::FilePath | ( | FilePath && | filePath | ) |
Move constructor.
| [in] | filePath | File path to move |
| cppfs::FilePath::FilePath | ( | const std::string & | path | ) |
Constructor.
| [in] | path | File path |
| cppfs::FilePath::FilePath | ( | std::string && | path | ) |
Constructor.
| [in] | path | File path |
| cppfs::FilePath::FilePath | ( | const char * | path | ) |
Constructor.
| [in] | string | File path |
|
virtual |
Destructor.
Copy assignment operator.
| [in] | filePath | Right-hand value to copy |
Move assignment operator.
| [in] | filePath | Right-hand value to move |
| const std::string& cppfs::FilePath::path | ( | ) | const |
Get path as string.
| void cppfs::FilePath::setPath | ( | const std::string & | path | ) |
Set path.
| [in] | path | File path |
| void cppfs::FilePath::setPath | ( | std::string && | path | ) |
Set path.
| [in] | path | File path |
| std::string cppfs::FilePath::toNative | ( | ) | const |
Get native path as string.
| bool cppfs::FilePath::isEmpty | ( | ) | const |
Check if path is empty.
| bool cppfs::FilePath::pointsToContent | ( | ) | const |
Check if path points to the contents of a directory or container.
| const std::string& cppfs::FilePath::fullPath | ( | ) | const |
Get full path.
| const std::string& cppfs::FilePath::fileName | ( | ) | const |
Get file name.
| const std::string& cppfs::FilePath::baseName | ( | ) | const |
Get base name.
| const std::string& cppfs::FilePath::extension | ( | ) | const |
Get file extension.
| const std::string& cppfs::FilePath::directoryPath | ( | ) | const |
Get directory path.
| const std::string& cppfs::FilePath::driveLetter | ( | ) | const |
Get drive letter.
| bool cppfs::FilePath::isAbsolute | ( | ) | const |
Check if path is absolute.
| bool cppfs::FilePath::isRelative | ( | ) | const |
Check if path is relative.
Resolve relative path from this path.
| [in] | path | Path |
| std::string cppfs::FilePath::resolved | ( | ) | const |
Resolve path (removed '.' and '..' entries if possible)
| [in] | path | Path |
|
protected |
Analyze path and fill in the additional information.
|
protected |
Path (unified format)
|
protected |
'true' if the path has a trailing separator, else 'false'
|
mutableprotected |
'true' if path details have been analyzed, else 'false'
|
mutableprotected |
Full path (without trailing separators)
|
mutableprotected |
Filename component.
|
mutableprotected |
Basename component.
|
mutableprotected |
Extension component.
|
mutableprotected |
Path to containing directory.
|
mutableprotected |
Drive letter component.
|
mutableprotected |
'true' if path is absolute, else 'false'
1.8.11