17#include <linux/limits.h>
32namespace fs = std::filesystem;
35using perms = fs::perms;
36using copy_options = fs::copy_options;
37using perm_options = fs::perm_options;
45[[nodiscard]]
inline std::expected<fs::path, std::string>
realpath(fs::path
const& path_file_src)
47 char str_path_file_resolved[PATH_MAX];
48 if (
::realpath(path_file_src.c_str(), str_path_file_resolved) ==
nullptr )
50 return std::unexpected<std::string>(strerror(errno));
52 return fs::path{str_path_file_resolved};
63 std::vector<fs::path> files = Try(fs::directory_iterator(path_dir_src))
64 | std::views::transform([](
auto&& e){
return e.path(); })
65 | std::views::filter([](
auto&& e){
return fs::is_regular_file(e); })
66 | std::ranges::to<std::vector<fs::path>>();
78 if(Try(fs::exists(p)))
82 if (not Try(fs::create_directories(p)))
84 return std::unexpected(std::format(
"Could not create directory {}", p.string()));
100template<
typename... Args>
Enhanced error handling framework built on std::expected.
Enhanced filesystem utilities wrapping std::filesystem.
Value< std::vector< fs::path > > regular_files(fs::path const &path_dir_src)
List the files in a directory.
fs::path placeholders_replace(fs::path const &path, Args &&... args)
Replace placeholders in a path by traversing components.
std::expected< fs::path, std::string > realpath(fs::path const &path_file_src)
Resolves an input path using realpath(3)
Value< fs::path > create_directories(fs::path const &p)
Creates directories recursively.
std::string placeholders_replace(std::string str, Args &&... args)
Replace all occurrences of "{}" placeholders in a string with provided values.
Enhanced expected type with integrated logging capabilities.