12 namespace stdfs = std::filesystem;
15 using stdfs::file_status;
16 using stdfs::file_type;
17 using stdfs::file_time_type;
19#define GHPL_CALL_WEC(fname) []<typename... ARGS>(ARGS&&... args) { return fname(std::forward<ARGS>(args)...); }
21 inline auto absolute(
const stdfs::path& path) {
return call_with_expected_ec(GHPL_CALL_WEC(stdfs::absolute), path); }
22 inline auto canonical(
const stdfs::path& path) {
return call_with_expected_ec(GHPL_CALL_WEC(stdfs::canonical), path); }
23 inline auto weakly_canonical(
const stdfs::path& path) {
return call_with_expected_ec(GHPL_CALL_WEC(stdfs::weakly_canonical), path); }
25 inline auto relative(
const stdfs::path&
p,
const stdfs::path& base = stdfs::current_path()) {
return call_with_expected_ec(GHPL_CALL_WEC(stdfs::relative),
p, base); }
26 inline auto proximate(
const stdfs::path&
p) {
return call_with_expected_ec(GHPL_CALL_WEC(stdfs::proximate),
p); }
27 inline auto proximate(
const stdfs::path&
p,
const stdfs::path& base = stdfs::current_path()) {
return call_with_expected_ec(GHPL_CALL_WEC(stdfs::proximate),
p, base); }
28 inline auto copy(
const stdfs::path& from,
const stdfs::path&
to)
noexcept {
return call_with_expected_ec(GHPL_CALL_WEC(stdfs::copy), from,
to); }
30 inline auto copy_file(
const stdfs::path& from,
const stdfs::path&
to)
noexcept {
return call_with_expected_ec(GHPL_CALL_WEC(stdfs::copy_file), from,
to); }
31 inline auto copy_file(
const stdfs::path& from,
const stdfs::path&
to, stdfs::copy_options
options)
noexcept {
return call_with_expected_ec(GHPL_CALL_WEC(stdfs::copy_file), from,
to,
options); }
34 inline auto create_directory(
const stdfs::path&
p)
noexcept {
return call_with_expected_ec(GHPL_CALL_WEC(stdfs::create_directory),
p); }
36 inline auto create_directories(
const stdfs::path&
p) {
return call_with_expected_ec(GHPL_CALL_WEC(stdfs::create_directories),
p); }
41 inline auto current_path(
const stdfs::path&
p)
noexcept {
return call_with_expected_ec(GHPL_CALL_WEC(stdfs::current_path),
p); }
42 inline bool exists(stdfs::file_status
s)
noexcept {
return stdfs::exists(
s); }
43 inline auto exists(
const stdfs::path&
p)
noexcept {
return call_with_expected_ec(GHPL_CALL_WEC(stdfs::exists),
p); }
44 inline auto equivalent(
const stdfs::path& p1,
const stdfs::path& p2)
noexcept {
return call_with_expected_ec(GHPL_CALL_WEC(stdfs::equivalent), p1, p2); }
45 inline auto file_size(
const stdfs::path&
p)
noexcept {
return call_with_expected_ec(GHPL_CALL_WEC(stdfs::file_size),
p); }
46 inline auto hard_link_count(
const stdfs::path&
p)
noexcept {
return call_with_expected_ec(GHPL_CALL_WEC(stdfs::hard_link_count),
p); }
47 inline auto last_write_time(
const stdfs::path& path)
noexcept {
return call_with_expected_ec(GHPL_CALL_WEC(stdfs::last_write_time), path); }
48 inline auto last_write_time(
const stdfs::path& path, stdfs::file_time_type
new_time)
noexcept {
return call_with_expected_ec(GHPL_CALL_WEC(stdfs::last_write_time), path,
new_time); }
50 inline auto permissions(
const stdfs::path&
p, stdfs::perms
prms, stdfs::perm_options
opts = stdfs::perm_options::replace) {
return call_with_expected_ec(GHPL_CALL_WEC(stdfs::permissions),
p,
prms,
opts); }
51 inline auto read_symlink(
const stdfs::path&
p) {
return call_with_expected_ec(GHPL_CALL_WEC(stdfs::read_symlink),
p); }
52 inline auto remove(
const stdfs::path&
p)
noexcept {
return call_with_expected_ec(GHPL_CALL_WEC(stdfs::remove),
p); }
53 inline auto remove_all(
const stdfs::path&
p) {
return call_with_expected_ec(GHPL_CALL_WEC(stdfs::remove_all),
p); }
54 inline auto rename(
const stdfs::path& from,
const stdfs::path&
to)
noexcept {
return call_with_expected_ec(GHPL_CALL_WEC(stdfs::rename), from,
to); }
56 inline auto space(
const stdfs::path&
p)
noexcept {
return call_with_expected_ec(GHPL_CALL_WEC(stdfs::space),
p); }
57 inline auto status(
const stdfs::path&
p)
noexcept {
return call_with_expected_ec(GHPL_CALL_WEC(stdfs::status),
p); }
58 inline auto status_known(stdfs::file_status
s)
noexcept {
return stdfs::status_known(
s); }
59 inline auto symlink_status(
const stdfs::path&
p)
noexcept {
return call_with_expected_ec(GHPL_CALL_WEC(stdfs::symlink_status),
p); }
60 inline auto temp_directory_path() {
return call_with_expected_ec(GHPL_CALL_WEC(stdfs::temp_directory_path)); }
62 inline auto is_block_file(stdfs::file_status
s)
noexcept {
return stdfs::is_block_file(
s); }
63 inline auto is_block_file(
const stdfs::path&
p) {
return call_with_expected_ec(GHPL_CALL_WEC(stdfs::is_block_file),
p); }
64 inline auto is_character_file(stdfs::file_status
s)
noexcept {
return stdfs::is_character_file(
s); }
65 inline auto is_character_file(
const stdfs::path&
p) {
return call_with_expected_ec(GHPL_CALL_WEC(stdfs::is_character_file),
p); }
66 inline auto is_directory(stdfs::file_status
s)
noexcept {
return stdfs::is_directory(
s); }
67 inline auto is_directory(
const stdfs::path&
p) {
return call_with_expected_ec(GHPL_CALL_WEC(stdfs::is_directory),
p); }
69 inline auto is_fifo(stdfs::file_status
s)
noexcept {
return stdfs::is_fifo(
s); }
71 inline auto is_other(stdfs::file_status
s)
noexcept {
return stdfs::is_other(
s); }
73 inline auto is_regular_file(stdfs::file_status
s)
noexcept {
return stdfs::is_regular_file(
s); }
74 inline auto is_regular_file(
const stdfs::path&
p) {
return call_with_expected_ec(GHPL_CALL_WEC(stdfs::is_regular_file),
p); }
75 inline auto is_socket(stdfs::file_status
s)
noexcept {
return stdfs::is_socket(
s); }
76 inline auto is_socket(
const stdfs::path&
p) {
return call_with_expected_ec(GHPL_CALL_WEC(stdfs::is_socket),
p); }
77 inline auto is_symlink(stdfs::file_status
s)
noexcept {
return stdfs::is_symlink(
s); }
78 inline auto is_symlink(
const stdfs::path&
p) {
return call_with_expected_ec(GHPL_CALL_WEC(stdfs::is_symlink),
p); }
86 static_assert(stdfs::path::preferred_separator < 128);
88 if (
p.is_absolute() ||
to.empty())
94 while (
to.ends_with(stdfs::path::preferred_separator))
97 auto str =
p.string();
98 auto sv = std::string_view{ str };
99 while (
sv.starts_with(stdfs::path::preferred_separator))
102 to += (
char)stdfs::path::preferred_separator;
105 to = (
to /
p).
string();
constexpr auto bit_count
Equal to the number of bits in the type.
constexpr CONTAINER to(RANGE &&range, TYPES &&... args)
to<container>();
auto copy_symlink(const stdfs::path &from, const stdfs::path &to)
This is supposed to be noexcept but msvc's impl isn't.
void path_append(std::string &to, path const &p)
As if to /= p
auto call_with_expected_ec(FUNC &&func, ARGS &&... args) noexcept(noexcept(func(std::forward< ARGS >(args)...))) -> expected< std::invoke_result_t< FUNC, ARGS &&... >, std::error_code >
Calls the given function with args and an std::error_code as the last argument.