FilesystemUtils
Functions
Name | |
---|---|
bool | anyEquivalent(const fs::path & path1, const fs::path & path2)<br>Compares two paths either using equivalent() or weaklyEquivalent(). |
bool | copy(const fs::path & from, const fs::path & to, const fs::copy_options options =fs::copy_options::overwrite_existing |
bool | copyFile(const fs::path & from, const fs::path & to, const fs::copy_options options =fs::copy_options::overwrite_existing)<br>Copy file to a location. |
bool | copyToDir(const fs::path & from, const fs::path & toDir, const fs::copy_options options =fs::copy_options::overwrite_existing |
bool | deleteFileOrDir(const fs::path & path, bool deleteEmptyFolders =false)<br>Remove the specified file or directories. |
bool | equivalent(const fs::path & path1, const fs::path & path2)<br>Compare two paths with exception handling. |
bool | isSubpath(const fs::path path, const fs::path base)<br>Checks if a path is located "downstream" from a base location. |
fs::path | normalizePath(const fs::path & originalPath) |
Result< std::string, Error > | readFile(const fs::path & path) |
void | reportFilesystemException(const fs::filesystem_error & e) |
bool | weaklyEquivalent(const fs::path & path1, const fs::path & path2)<br>Compare two paths with exception handling. |
Functions Documentation
function anyEquivalent
inline bool anyEquivalent(
const fs::path & path1,
const fs::path & path2
)
inline bool anyEquivalent(
const fs::path & path1,
const fs::path & path2
)
Compares two paths either using equivalent() or weaklyEquivalent().
The weak equivalence is used when either of the two paths don't exist.
function copy
inline bool copy(
const fs::path & from,
const fs::path & to,
const fs::copy_options options =fs::copy_options::overwrite_existing|fs::copy_options::recursive
)
inline bool copy(
const fs::path & from,
const fs::path & to,
const fs::copy_options options =fs::copy_options::overwrite_existing|fs::copy_options::recursive
)
Copy file or directory to a location.
Return: Whether the copy operation succeeded or not
The target location directory is created if necessary. Filesystem exceptions are handled and reported by this method.
function copyFile
inline bool copyFile(
const fs::path & from,
const fs::path & to,
const fs::copy_options options =fs::copy_options::overwrite_existing
)
inline bool copyFile(
const fs::path & from,
const fs::path & to,
const fs::copy_options options =fs::copy_options::overwrite_existing
)
Copy file to a location.
Return: Whether the copy operation succeeded or not
The target location directory is created if necessary. Filesystem exceptions are handled and reported by this method.
function copyToDir
inline bool copyToDir(
const fs::path & from,
const fs::path & toDir,
const fs::copy_options options =fs::copy_options::overwrite_existing|fs::copy_options::recursive
)
inline bool copyToDir(
const fs::path & from,
const fs::path & toDir,
const fs::copy_options options =fs::copy_options::overwrite_existing|fs::copy_options::recursive
)
Copy file or directory to another directory.
Return: Whether the copy operation succeeded or not
The target location directory is created if necessary. Filesystem exceptions are handled and reported by this method.
function deleteFileOrDir
inline bool deleteFileOrDir(
const fs::path & path,
bool deleteEmptyFolders =false
)
inline bool deleteFileOrDir(
const fs::path & path,
bool deleteEmptyFolders =false
)
Remove the specified file or directories.
Parameters:
- path The file or directory to delete.
- deleteEmptyFolders If true, any empty parent directories of the specified file or dir will be deleted as well up recursively until the root directory.
Return: Whether the delete operation succeeded.
Directories are deleted recursively.
function equivalent
inline bool equivalent(
const fs::path & path1,
const fs::path & path2
)
inline bool equivalent(
const fs::path & path1,
const fs::path & path2
)
Compare two paths with exception handling.
Calls the fs::equivalent method directly which checks if two paths are pointing to the same EXISTING file. Thus both paths MUST exist for this method to not throw an exception. Use the weaklyEquivalent() method if any of the paths don't exist.
function isSubpath
inline bool isSubpath(
const fs::path path,
const fs::path base
)
inline bool isSubpath(
const fs::path path,
const fs::path base
)
Checks if a path is located "downstream" from a base location.
This check if performed by inspecting the relative path between these two locations. The relative path must not start with going "up" a directory.
function normalizePath
inline fs::path normalizePath(
const fs::path & originalPath
)
inline fs::path normalizePath(
const fs::path & originalPath
)
function readFile
Result< std::string, Error > readFile(
const fs::path & path
)
Result< std::string, Error > readFile(
const fs::path & path
)
function reportFilesystemException
inline void reportFilesystemException(
const fs::filesystem_error & e
)
inline void reportFilesystemException(
const fs::filesystem_error & e
)
function weaklyEquivalent
inline bool weaklyEquivalent(
const fs::path & path1,
const fs::path & path2
)
inline bool weaklyEquivalent(
const fs::path & path1,
const fs::path & path2
)
Compare two paths with exception handling.
Uses mostly string comparison trickery. The paths do NOT have to exist.
Updated on 2024-11-06 at 20:16:53 +0000