![]() |
Limo
A simple mod manager
|
Contains utility functions for dealing with std::filesystem::path objects. More...
Functions | |
std::optional< sfs::path > | pathExists (const sfs::path &path_to_check, const sfs::path &base_path, bool case_insensitive) |
std::string | toLowerCase (const sfs::path &path) |
void | moveFilesToDirectory (const sfs::path &source, const sfs::path &destination, bool move) |
std::string | normalizePath (const std::string &path) |
Replaces all double backslash path separators with a forward slash. | |
std::string | getRelativePath (sfs::path target, sfs::path source) |
bool | directoryIsEmpty (const sfs::path &directory, std::vector< std::string > ignored_files) |
int | getPathLength (const sfs::path &path) |
std::pair< sfs::path, sfs::path > | removePathComponents (const sfs::path &path, int depth) |
void | renameFiles (const sfs::path &destination, const sfs::path &source, std::function< unsigned char(unsigned char)> converter) |
void | moveFilesWithDepth (const sfs::path &source, const sfs::path &destination, int depth) |
void | copyOrMoveFiles (const sfs::path &source, const sfs::path &destination, bool move) |
bool | exists (const std::filesystem::path &path) |
Checks whether the given path exists. This differs from std::filesystem::exists in that true is returned even if path points to an invalid symlink. | |
std::optional< std::filesystem::path > | pathExists (const std::filesystem::path &path_to_check, const std::filesystem::path &base_path, bool case_insensitive=true) |
Checks if the target path exists. | |
std::string | toLowerCase (const std::filesystem::path &path) |
Returns a string containing the given path in lower case. | |
void | moveFilesToDirectory (const std::filesystem::path &source, const std::filesystem::path &destination, bool move=true) |
Recursively moves all files from the source directory to the target directory. | |
std::string | getRelativePath (std::filesystem::path target, std::filesystem::path source) |
Determines the relative path from source to target. Only works if source.string() is a sub-string of target.string(). | |
bool | directoryIsEmpty (const std::filesystem::path &directory, std::vector< std::string > ignored_files={}) |
Returns true if directory is empty or contains only empty directories. | |
int | getPathLength (const std::filesystem::path &path) |
Returns the number of elements in given path. | |
std::pair< std::filesystem::path, std::filesystem::path > | removePathComponents (const std::filesystem::path &path, int depth) |
Removes the first components of a given path. | |
void | renameFiles (const std::filesystem::path &destination, const std::filesystem::path &source, std::function< unsigned char(unsigned char)> converter) |
Recursively renames all files at given source directory using given converter, then copies the result to given destination directory. | |
void | moveFilesWithDepth (const std::filesystem::path &source, const std::filesystem::path &destination, int depth) |
Recursively moves all files from source to destination, removes all path components with depth < root_level. | |
void | copyOrMoveFiles (const std::filesystem::path &source, const std::filesystem::path &destination, bool move) |
Copies or moves files from source to dest. | |
Contains utility functions for dealing with std::filesystem::path objects.
void path_utils::copyOrMoveFiles | ( | const std::filesystem::path & | source, |
const std::filesystem::path & | destination, | ||
bool | move ) |
Copies or moves files from source to dest.
source | Copy/ move source path. |
destination | Copy/ move target path. |
move | If true: Move files, else: Recursively copy files. |
bool path_utils::directoryIsEmpty | ( | const std::filesystem::path & | directory, |
std::vector< std::string > | ignored_files = {} ) |
Returns true if directory is empty or contains only empty directories.
directory | Directory to check. |
ignored_files | Vector of file names to ignore. |
bool path_utils::exists | ( | const std::filesystem::path & | path | ) |
Checks whether the given path exists. This differs from std::filesystem::exists in that true is returned even if path points to an invalid symlink.
path | Path to check. |
int path_utils::getPathLength | ( | const std::filesystem::path & | path | ) |
Returns the number of elements in given path.
path | Path to be checked. |
std::string path_utils::getRelativePath | ( | std::filesystem::path | target, |
std::filesystem::path | source ) |
Determines the relative path from source to target. Only works if source.string() is a sub-string of target.string().
target | Target path. |
source | Source path. |
void path_utils::moveFilesToDirectory | ( | const std::filesystem::path & | source, |
const std::filesystem::path & | destination, | ||
bool | move = true ) |
Recursively moves all files from the source directory to the target directory.
source | Source directory. |
destination | Target directory. |
move | If false: Copy files instead of moving them. |
void path_utils::moveFilesWithDepth | ( | const std::filesystem::path & | source, |
const std::filesystem::path & | destination, | ||
int | depth ) |
Recursively moves all files from source to destination, removes all path components with depth < root_level.
source | Source path. |
destination | Destination path. |
depth | Minimum depth for path components to keep. |
std::string path_utils::normalizePath | ( | const std::string & | path | ) |
Replaces all double backslash path separators with a forward slash.
std::optional< std::filesystem::path > path_utils::pathExists | ( | const std::filesystem::path & | path_to_check, |
const std::filesystem::path & | base_path, | ||
bool | case_insensitive = true ) |
Checks if the target path exists.
target | Path to check. |
base_path | If specified, target path is appended to this path during the search. |
case_insensitive | If true: Ignore case mismatch for path search. |
std::pair< std::filesystem::path, std::filesystem::path > path_utils::removePathComponents | ( | const std::filesystem::path & | path, |
int | depth ) |
Removes the first components of a given path.
path | Source path. |
depth | Components with depth < this will be removed. |
void path_utils::renameFiles | ( | const std::filesystem::path & | destination, |
const std::filesystem::path & | source, | ||
std::function< unsigned char(unsigned char)> | converter ) |
Recursively renames all files at given source directory using given converter, then copies the result to given destination directory.
destination | Path to destination directory for renamed files. |
source | Path to source files to be renamed. |
converter | Function which converts one char to another, e.g. converting to upper case. |
std::string path_utils::toLowerCase | ( | const std::filesystem::path & | path | ) |
Returns a string containing the given path in lower case.
path | Path to be converted. |