fix: Various issues with UTF-8 paths

This commit is contained in:
WerWolv
2022-06-30 19:39:06 +02:00
parent 96aa929c31
commit 3db50a690c
6 changed files with 27 additions and 8 deletions

View File

@@ -313,4 +313,20 @@ namespace hex::fs {
return result;
}
std::fs::path toShortPath(const std::fs::path &path) {
#if defined(OS_WINDOWS)
size_t size = GetShortPathNameW(path.c_str(), nullptr, 0) * sizeof(TCHAR);
if (size == 0)
return path;
std::wstring newPath(size, 0x00);
GetShortPathNameW(path.c_str(), newPath.data(), newPath.size());
return newPath;
#else
return path;
#endif
}
}