12#include <system_error>
24template<
typename TString>
25concept StringLike = std::is_convertible_v<TString, std::string>
26 || std::is_convertible_v<TString, std::string_view>;
37 return "\\" + std::string(base);
39 return "/" + std::string(base);
54template<StringLike... Components>
78std::errc
mkdir(
const std::string& path);
88std::errc
rmdir(
const std::string& path);
116 return stat(path.c_str(), &st) == 0;
Type constraint for string-like types.
Definition file_utils.h:25
std::string canonical_path(const std::string &path)
Get the canonical path. The canonical path will not contain dot, dotdot or symlinks.
std::errc mkdir(const std::string &path)
Make a directory. This behaves as mkdir -p. It will create intermediary path components automatically...
std::errc rmdir(const std::string &path)
Delete a directory recursively. Behaves as rm -rf.
std::string temp_directory_path()
Get the path for the temp directory on the OS. Similar semantics to std::filesystem::temp_directory_p...
std::errc file_remove(const std::string &path)
Remove a file.
std::string path_separator(const StringLike auto &base)
Utility for prepending OS-specific path separator. Needed for the path_join function.
Definition file_utils.h:34
std::string path_join(const StringLike auto &base, Components... comp)
Utility to construct OS-aware paths. Similar to Python's os.path.join(). On Windows the path componen...
Definition file_utils.h:55
bool file_exists(const std::string &path)
Utility to check if a path exists. Same semantics as std::filesystem::exists, but won't do character ...
Definition file_utils.h:113
Any entities that belong to the utils library.