5 #ifndef BITCOIN_UTIL_FS_H 6 #define BITCOIN_UTIL_FS_H 17 #include <system_error> 18 #include <type_traits> 32 class path :
public std::filesystem::path
35 using std::filesystem::path::path;
39 path&
operator=(std::filesystem::path
path) { std::filesystem::path::operator=(std::move(
path));
return *
this; }
44 path&
operator=(
const char* c) { std::filesystem::path::operator=(c);
return *
this; }
45 path&
operator/=(
const char* c) { std::filesystem::path::operator/=(c);
return *
this; }
46 path&
append(
const char* c) { std::filesystem::path::append(c);
return *
this; }
49 path(std::string) =
delete;
50 path& operator=(std::string) =
delete;
51 path& operator/=(std::string) =
delete;
52 path& append(std::string) =
delete;
55 std::string string()
const =
delete;
65 const std::u8string& utf8_str{std::filesystem::path::u8string()};
66 return std::string{utf8_str.begin(), utf8_str.end()};
72 path filename()
const {
return std::filesystem::path::filename(); }
77 return std::filesystem::path(std::u8string{utf8_str.begin(), utf8_str.end()});
95 static inline auto quoted(
const std::string& s)
123 template<
typename T>
static inline path
operator/(path p1, T p2) =
delete;
124 template<
typename T>
static inline path
operator+(path p1, T p2) =
delete;
166 static_assert(std::is_same<path::string_type, std::string>::value,
"PathToString not implemented on this platform");
167 return path.std::filesystem::path::string();
179 return std::filesystem::path(
string);
192 if (std::filesystem::is_symlink(p) && std::filesystem::is_directory(p)) {
203 bool create_directories(
const std::filesystem::path& p, std::error_code& ec) =
delete;
209 using FopenFn = std::function<FILE*(const fs::path&, const char*)>;
239 void* hFile = (
void*)-1;
249 template<>
inline void formatValue(std::ostream&,
const char*,
const char*,
int,
const std::filesystem::path&) =
delete;
250 template<>
inline void formatValue(std::ostream&,
const char*,
const char*,
int,
const fs::path&) =
delete;
253 #endif // BITCOIN_UTIL_FS_H bool create_directories(const std::filesystem::path &p, std::error_code &ec)=delete
This variant is not used.
static path PathFromString(const std::string &string)
Convert byte string to path object.
path & append(const char *c)
fs::path AbsPathJoin(const fs::path &base, const fs::path &path)
Helper function for joining two paths.
FILE * fopen(const fs::path &p, const char *mode)
Bridge operations to C stdio.
Filesystem operations and types.
path & operator/=(const std::filesystem::path &path)
std::function< FILE *(const fs::path &, const char *)> FopenFn
static std::string PathToString(const path &path)
Convert path object to a byte string.
static path operator/(path p1, const path &p2)
path & operator/=(const char *c)
path(std::filesystem::path path)
static bool create_directories(const std::filesystem::path &p)
Create directory (and if necessary its parents), unless the leaf directory already exists or is a sym...
path & operator=(const char *c)
static path operator+(path p1, const char *p2)
std::string get_filesystem_error_message(const fs::filesystem_error &e)
std::string utf8string() const
Return a UTF-8 representation of the path as a std::string, for compatibility with code using std::st...
static auto quoted(const std::string &s)
static bool exists(const path &p)
static path u8path(const std::string &utf8_str)
Path class wrapper to block calls to the fs::path(std::string) implicit constructor and the fs::path:...
static path absolute(const path &p)
path & operator=(std::filesystem::path path)
static bool copy_file(const path &from, const path &to, copy_options options)