Limo
A simple mod manager
Loading...
Searching...
No Matches
pathutils.h File Reference

Header for the path_utils namespace. More...

#include <filesystem>
#include <functional>
#include <optional>
Include dependency graph for pathutils.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  path_utils
 Contains utility functions for dealing with std::filesystem::path objects.
 

Functions

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.
 
std::string path_utils::toLowerCase (const std::filesystem::path &path)
 Returns a string containing the given path in lower case.
 
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.
 
std::string path_utils::normalizePath (const std::string &path)
 Replaces all double backslash path separators with a forward slash.
 
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().
 
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.
 
int path_utils::getPathLength (const std::filesystem::path &path)
 Returns the number of elements in given path.
 
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.
 
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.
 
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.
 
void path_utils::copyOrMoveFiles (const std::filesystem::path &source, const std::filesystem::path &destination, bool move)
 Copies or moves files from source to dest.
 
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.
 

Detailed Description

Header for the path_utils namespace.