Skip to content

FilesystemUtils

Functions

Name
boolcopy(const fs::path & from, const fs::path & to, const fs::copy_options options =fs::copy_options::overwrite_existing
boolcopyFile(const fs::path & from, const fs::path & to, const fs::copy_options options =fs::copy_options::overwrite_existing)<br>Copy file to a location.
boolcopyToDir(const fs::path & from, const fs::path & toDir, const fs::copy_options options =fs::copy_options::overwrite_existing
booldeleteFileOrDir(const fs::path & path, bool deleteEmptyFolders =false)<br>Remove the specified file or directories.
booldoesFileExist(const std::string & path)
booldoesFileExists(const char * filename)
booldoesFileExists(fs::path & path)
boolequivalent(const fs::path & path1, const fs::path & path2)<br>Compare two paths with exception handling.
boolisSubpath(const fs::path path, const fs::path base)<br>Checks if a path is located "downstream" from a base location.
fs::pathnormalizePath(const fs::path & originalPath)
voidreportFilesystemException(const fs::filesystem_error & e)
boolweaklyEquivalent(const fs::path & path1, const fs::path & path2)<br>Compare two paths with exception handling.

Functions Documentation

function copy

cpp
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

cpp
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

cpp
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

cpp
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 doesFileExist

cpp
inline bool doesFileExist(
    const std::string & path
)
inline bool doesFileExist(
    const std::string & path
)

Parameters:

  • path Absolute

Return:

function doesFileExists

cpp
inline bool doesFileExists(
    const char * filename
)
inline bool doesFileExists(
    const char * filename
)

function doesFileExists

cpp
inline bool doesFileExists(
    fs::path & path
)
inline bool doesFileExists(
    fs::path & path
)

Parameters:

  • path Absolute

Return:

function equivalent

cpp
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.

Note that both paths MUST exist for this method to return true. Use the weaklyEquivalent() method if any of the paths doesn't exist.

function isSubpath

cpp
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

cpp
inline fs::path normalizePath(
    const fs::path & originalPath
)
inline fs::path normalizePath(
    const fs::path & originalPath
)

function reportFilesystemException

cpp
inline void reportFilesystemException(
    const fs::filesystem_error & e
)
inline void reportFilesystemException(
    const fs::filesystem_error & e
)

function weaklyEquivalent

cpp
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.

The paths do NOT have to exist.


Updated on 2024-03-16 at 19:15:01 +0000