mirror of
https://github.com/mhx/dwarfs.git
synced 2025-09-22 02:40:23 -04:00
fix: Windows paths suck, really
This commit is contained in:
parent
b136bbaf86
commit
8e32947bdc
@ -306,15 +306,17 @@ void shorten_path_string(std::string& path, char separator, size_t max_len) {
|
||||
|
||||
std::filesystem::path canonical_path(std::filesystem::path p) {
|
||||
if (!p.empty()) {
|
||||
#ifdef _WIN32
|
||||
p = std::filesystem::path(L"\\\\?\\" + p.wstring());
|
||||
#endif
|
||||
|
||||
try {
|
||||
p = std::filesystem::canonical(p);
|
||||
} catch (std::filesystem::filesystem_error const&) {
|
||||
p = std::filesystem::absolute(p);
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
if (auto wstr = p.wstring(); !wstr.starts_with(L"\\\\")) {
|
||||
p = std::filesystem::path(L"\\\\?\\" + wstr);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
return p;
|
||||
|
Loading…
x
Reference in New Issue
Block a user