Skip to content

Commit

Permalink
fix: Windows paths suck, really
Browse files Browse the repository at this point in the history
  • Loading branch information
mhx committed Feb 13, 2024
1 parent b136bba commit 8e32947
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/dwarfs/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

1 comment on commit 8e32947

@theintel
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does. It does.

Please sign in to comment.