#include <tools/FilesystemPath.hpp>
◆ FilesystemPath() [1/3]
openfluid::tools::FilesystemPath::FilesystemPath |
( |
const std::string & |
PathStr | ) |
|
Constructs a FilesystemPath object using a string
- Parameters
-
[in] | PathStr | the path as a string |
◆ FilesystemPath() [2/3]
openfluid::tools::FilesystemPath::FilesystemPath |
( |
const char * |
PathStr | ) |
|
Constructs a FilesystemPath object using a C-style string
- Parameters
-
[in] | PathStr | the path as a char* |
◆ FilesystemPath() [3/3]
openfluid::tools::FilesystemPath::FilesystemPath |
( |
const std::vector< std::string > & |
PathParts | ) |
|
Constructs a FilesystemPath object using a vector of strings that will be joined using the path separator
- Parameters
-
[in] | PathParts | the path as a string vector |
◆ basename()
std::string openfluid::tools::FilesystemPath::basename |
( |
| ) |
const |
Returns the complete base name of the path (without latest extension part, without trailing dot if any)
std::string Name = ExamplePath.basename();
- Returns
- the base name of the file
◆ completeExtension()
std::string openfluid::tools::FilesystemPath::completeExtension |
( |
| ) |
const |
Returns the complete extension (without first dot character) of the path
std::string Ext = ExamplePath.completeExtension();
- Returns
- the complete extension
◆ contains()
bool openfluid::tools::FilesystemPath::contains |
( |
const std::string & |
Path | ) |
const |
Returns true if a the path contains a child path (e.g. /path/to contains /path/to/child/path)
- Parameters
-
- Returns
- true or false
◆ dirname()
std::string openfluid::tools::FilesystemPath::dirname |
( |
| ) |
const |
Returns the directory name (parent path)
std::string Name = ExamplePath.dirname();
- Returns
- the directory name
◆ empty()
bool openfluid::tools::FilesystemPath::empty |
( |
| ) |
const |
Returns true if the current strored path is empty
- Returns
- true if the current strored path is empty, false otherwise
◆ exists()
bool openfluid::tools::FilesystemPath::exists |
( |
const std::string & |
Path = "" | ) |
const |
Returns true if the path exists (a file, a directory or a valid symbolic link)
- Parameters
-
[in] | Path | a relative path added to the to the base path (optional, none by default) |
- Returns
- true or false
◆ extension()
std::string openfluid::tools::FilesystemPath::extension |
( |
| ) |
const |
Returns the extension (without dot character) of the path
std::string Ext = ExamplePath.extension();
- Returns
- the extension
◆ filename()
std::string openfluid::tools::FilesystemPath::filename |
( |
| ) |
const |
Returns the filename of the path
std::string Name = ExamplePath.filename();
- Returns
- the filename
◆ fromStdPath()
static FilesystemPath openfluid::tools::FilesystemPath::fromStdPath |
( |
const std::filesystem::path & |
StdPath | ) |
|
|
static |
Creates a FilesystemPath object from a std::filesystem::path object
- Parameters
-
[in] | StdPath | the std::filesystem::path object |
- Returns
- The newly created FilesystemPath object
◆ fromThis() [1/2]
FilesystemPath openfluid::tools::FilesystemPath::fromThis |
( |
const std::string & |
PathStr = "" | ) |
const |
Creates a new FilesystemPath object from the current FilesystemPath object.
- Parameters
-
[in] | PathStr | a relative path added to the to the current stored path (optional, none by default) |
- Returns
- The newly created FilesystemPath object
◆ fromThis() [2/2]
FilesystemPath openfluid::tools::FilesystemPath::fromThis |
( |
const std::vector< std::string > & |
PathParts | ) |
const |
Creates a new FilesystemPath object from the current FilesystemPath object.
- Parameters
-
[in] | PathParts | a relative joined path added to the to the current stored path (optional, none by default) |
- Returns
- The newly created FilesystemPath object
◆ isDirectory()
bool openfluid::tools::FilesystemPath::isDirectory |
( |
const std::string & |
Path = "" | ) |
const |
Returns true if the path is a directory
- Parameters
-
[in] | Path | a relative path added to the to the base path (optional, none by default) |
- Returns
- true or false
◆ isFile()
bool openfluid::tools::FilesystemPath::isFile |
( |
const std::string & |
Path = "" | ) |
const |
Returns true if the path is a file or a valid symbolic link
- Parameters
-
[in] | Path | a relative path added to the to the base path (optional, none by default) |
- Returns
- true or false
◆ listSeparator()
constexpr static char openfluid::tools::FilesystemPath::listSeparator |
( |
| ) |
|
|
inlinestaticconstexprnoexcept |
Returns the separator used in paths lists according to current operating system
- Returns
- the list separator character
◆ makeDirectory()
bool openfluid::tools::FilesystemPath::makeDirectory |
( |
const std::string & |
Path = "" , |
|
|
std::error_code & |
ErrorCode = DefaultErrorCode |
|
) |
| const |
Creates the directory of the path. It creates all parent directories necessary to create the directory. If the directory already exists, it does nothing.
- Parameters
-
[in] | Path | a relative path added to the to the base path (optional, none by default) |
[in] | ErrorCode | the storage variable for eventual Error code returned by operation |
- Returns
- true if the directory has been successfully created or if it already exists, false otherwise
◆ makeFile()
bool openfluid::tools::FilesystemPath::makeFile |
( |
const std::string & |
Path = "" | ) |
const |
Creates an empty file at the path. It creates all parent directories necessary to create the file. If the file already exists, it does nothing.
- Parameters
-
[in] | Path | a relative path added to the to the base path (optional, none by default) |
- Returns
- true if the file has been successfully created or if it already exists, false otherwise
◆ minimalBasename()
std::string openfluid::tools::FilesystemPath::minimalBasename |
( |
| ) |
const |
Returns the minimal base name of the path (e.g. without any extension part, without trailing dot if any)
std::string Name = ExamplePath.minimalBasename();
- Returns
- the minimal base name of the file
◆ relativeTo()
std::string openfluid::tools::FilesystemPath::relativeTo |
( |
const std::string & |
Path | ) |
const |
Returns the resulting path relative to a given path (e.g with path /path/to/this/place relatively to given path /path/to, resulting path is this/place)
- Parameters
-
- Returns
- the resulting relative path
◆ remove()
bool openfluid::tools::FilesystemPath::remove |
( |
const std::string & |
Path = "" , |
|
|
std::error_code & |
ErrorCode = DefaultErrorCode |
|
) |
| const |
Removes the file or directory of the path.
- Parameters
-
[in] | Path | a relative path added to the to the base path (optional, none by default) |
[in] | ErrorCode | the storage variable for eventual Error code returned by operation |
- Returns
- true if the file was successfully deleted, false otherwise
◆ removeDirectory()
bool openfluid::tools::FilesystemPath::removeDirectory |
( |
const std::string & |
Path = "" , |
|
|
std::error_code & |
ErrorCode = DefaultErrorCode |
|
) |
| const |
Removes the directory of the path. It recursively deletes all contents of the directory.
- Parameters
-
[in] | Path | a relative path added to the to the base path (optional, none by default) |
[in] | ErrorCode | the storage variable for eventual Error code returned by operation |
- Returns
- true if the directory has been successfully deleted, false otherwise
◆ removeFile()
bool openfluid::tools::FilesystemPath::removeFile |
( |
const std::string & |
Path = "" , |
|
|
std::error_code & |
ErrorCode = DefaultErrorCode |
|
) |
| const |
Removes the file of the path.
- Parameters
-
[in] | Path | a relative path added to the to the base path (optional, none by default) |
[in] | ErrorCode | the storage variable for eventual Error code returned by operation |
- Returns
- true if the file was successfully deleted, false otherwise
◆ removeTrailingSeparators()
static std::string openfluid::tools::FilesystemPath::removeTrailingSeparators |
( |
const std::string & |
Path, |
|
|
char |
Sep = '/' |
|
) |
| |
|
staticnoexcept |
Removes trailing separators in the given path, if any.
- Parameters
-
[in] | Path | the path |
[in] | Sep | the separator character (default is '/') |
- Returns
- the path without any trailing separator
◆ separator()
constexpr static char openfluid::tools::FilesystemPath::separator |
( |
| ) |
|
|
inlinestaticconstexprnoexcept |
Returns the path separator according to current operating system
- Returns
- the path separator character
◆ split()
std::vector<std::string> openfluid::tools::FilesystemPath::split |
( |
| ) |
const |
Returns parts of the path, splitted using the path separator
- Returns
- the path parts
◆ stdPath()
const std::filesystem::path& openfluid::tools::FilesystemPath::stdPath |
( |
| ) |
const |
Returns a const reference to the internally stored path (std::filesystem::path)
◆ toGeneric()
std::string openfluid::tools::FilesystemPath::toGeneric |
( |
| ) |
const |
Returns the path as a path with generic paths separators (always '/')
- Returns
- the cleaned path with generic separators
◆ toGenericClean()
std::string openfluid::tools::FilesystemPath::toGenericClean |
( |
| ) |
const |
Returns the path as a cleaned path with generic paths separators (always '/')
- Returns
- the cleaned path with generic separators
◆ toNative()
std::string openfluid::tools::FilesystemPath::toNative |
( |
| ) |
const |
Returns the path as a path with native paths separators (e.g. '/' on Unix systems, '\' on Windows systems)
- Returns
- the cleaned path with native separators
The documentation for this class was generated from the following file: