mirror of
https://github.com/mhx/dwarfs.git
synced 2025-09-09 20:41:04 -04:00
Fix canonical path on Windows when accessing mounted DwarFS image
This commit is contained in:
parent
b09dea238c
commit
d4d65a4d99
@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
#include <filesystem>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "dwarfs/types.h"
|
#include "dwarfs/types.h"
|
||||||
@ -49,4 +50,6 @@ size_t utf8_display_width(std::string const& str);
|
|||||||
|
|
||||||
void shorten_path_string(std::string& path, char separator, size_t max_len);
|
void shorten_path_string(std::string& path, char separator, size_t max_len);
|
||||||
|
|
||||||
|
std::filesystem::path canonical_path(std::filesystem::path p);
|
||||||
|
|
||||||
} // namespace dwarfs
|
} // namespace dwarfs
|
||||||
|
@ -173,4 +173,18 @@ void shorten_path_string(std::string& path, char separator, size_t max_len) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::filesystem::path canonical_path(std::filesystem::path p) {
|
||||||
|
try {
|
||||||
|
p = std::filesystem::canonical(p);
|
||||||
|
} catch (std::filesystem::filesystem_error const&) {
|
||||||
|
p = std::filesystem::absolute(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
p = std::filesystem::path(L"\\\\?\\" + p.wstring());
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace dwarfs
|
} // namespace dwarfs
|
||||||
|
@ -994,7 +994,7 @@ int option_hdl(void* data, char const* arg, int key,
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
opts->fsimage = std::filesystem::canonical(
|
opts->fsimage = canonical_path(
|
||||||
std::filesystem::path(reinterpret_cast<char8_t const*>(arg)));
|
std::filesystem::path(reinterpret_cast<char8_t const*>(arg)));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -676,11 +676,7 @@ int mkdwarfs_main(int argc, sys_char** argv) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
path = std::filesystem::canonical(path);
|
path = canonical_path(path);
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
path = std::filesystem::path(L"\\\\?\\" + path.wstring());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
bool recompress = vm.count("recompress");
|
bool recompress = vm.count("recompress");
|
||||||
rewrite_options rw_opts;
|
rewrite_options rw_opts;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user