@@ -55,25 +55,34 @@ SOFTWARE.
5555
5656namespace DFHack {
5757 namespace Filesystem {
58- DFHACK_EXPORT void init ();
59- DFHACK_EXPORT bool chdir (std::filesystem::path path) noexcept ;
60- DFHACK_EXPORT std::filesystem::path getcwd ();
61- DFHACK_EXPORT bool restore_cwd ();
62- DFHACK_EXPORT std::filesystem::path get_initial_cwd ();
63- DFHACK_EXPORT bool mkdir (std::filesystem::path path) noexcept ;
58+ DFHACK_EXPORT void init ();
59+ DFHACK_EXPORT bool chdir (std::filesystem::path path) noexcept ;
60+ DFHACK_EXPORT std::filesystem::path getcwd ();
61+ DFHACK_EXPORT bool restore_cwd ();
62+ DFHACK_EXPORT std::filesystem::path get_initial_cwd ();
63+ DFHACK_EXPORT bool mkdir (std::filesystem::path path) noexcept ;
6464 // returns true on success or if directory already exists
65- DFHACK_EXPORT bool mkdir_recursive (std::filesystem::path path) noexcept ;
66- DFHACK_EXPORT bool rmdir (std::filesystem::path path) noexcept ;
67- DFHACK_EXPORT bool stat (std::filesystem::path path, std::filesystem::file_status & info) noexcept ;
68- DFHACK_EXPORT bool exists (std::filesystem::path path) noexcept ;
69- DFHACK_EXPORT bool isfile (std::filesystem::path path) noexcept ;
70- DFHACK_EXPORT bool isdir (std::filesystem::path path) noexcept ;
71- DFHACK_EXPORT std::time_t mtime (std::filesystem::path path) noexcept ;
72- DFHACK_EXPORT int listdir (std::filesystem::path dir, std::vector<std::filesystem::path> & files) noexcept ;
65+ DFHACK_EXPORT bool mkdir_recursive (std::filesystem::path path) noexcept ;
66+ DFHACK_EXPORT bool rmdir (std::filesystem::path path) noexcept ;
67+ DFHACK_EXPORT bool stat (std::filesystem::path path, std::filesystem::file_status& info) noexcept ;
68+ DFHACK_EXPORT bool exists (std::filesystem::path path) noexcept ;
69+ DFHACK_EXPORT bool isfile (std::filesystem::path path) noexcept ;
70+ DFHACK_EXPORT bool isdir (std::filesystem::path path) noexcept ;
71+ DFHACK_EXPORT std::time_t mtime (std::filesystem::path path) noexcept ;
72+ DFHACK_EXPORT int listdir (std::filesystem::path dir, std::vector<std::filesystem::path>& files) noexcept ;
7373 // set include_prefix to false to prevent dir from being prepended to
7474 // paths returned in files
75- DFHACK_EXPORT int listdir_recursive (std::filesystem::path dir, std::map<std::filesystem::path, bool > & files,
75+ DFHACK_EXPORT int listdir_recursive (std::filesystem::path dir, std::map<std::filesystem::path, bool >& files,
7676 int depth = 10 , bool include_prefix = true ) noexcept ;
7777 DFHACK_EXPORT std::filesystem::path canonicalize (std::filesystem::path p) noexcept ;
78+ inline std::string as_string (std::filesystem::path path) noexcept
79+ {
80+ auto pStr = path.string ();
81+ if constexpr (std::filesystem::path::preferred_separator != ' /' )
82+ {
83+ std::ranges::replace (pStr, std::filesystem::path::preferred_separator, ' /' );
84+ }
85+ return pStr;
86+ }
7887 }
7988}
0 commit comments