From 001dfea501dc7d19dafcfb5003c87ca127597d67 Mon Sep 17 00:00:00 2001 From: Augusto Domingos Date: Sat, 19 Sep 2026 13:11:55 +0200 Subject: [PATCH] Preserve native windows paths in filesystem operations --- src/common/platform/sysWindowsFileIO.cpp | 41 ++++++++---------------- 1 file changed, 13 insertions(+), 28 deletions(-) diff --git a/src/common/platform/sysWindowsFileIO.cpp b/src/common/platform/sysWindowsFileIO.cpp index cbe1c2693..bbdc73d4e 100644 --- a/src/common/platform/sysWindowsFileIO.cpp +++ b/src/common/platform/sysWindowsFileIO.cpp @@ -477,18 +477,10 @@ bool SysFileSetLastAccessAndWriteTimeUtc(const std::filesystem::path& name, } void SysFileFindFiles(const std::filesystem::path& path, std::vector& out) { - std::string real_path = Common::ReplaceChar(Common::PathToGenericString(path), '\\', '/'); - if (!real_path.ends_with("/")) { - real_path += "/"; - } + const auto pattern = path / L"*"; - std::string pattern = real_path + "*"; - - HANDLE h = nullptr; - WIN32_FIND_DATAW data; - - auto wide_pattern = std::filesystem::path(pattern).wstring(); - h = FindFirstFileW(wide_pattern.c_str(), &data); + WIN32_FIND_DATAW data {}; + HANDLE h = FindFirstFileW(pattern.c_str(), &data); if (h == INVALID_HANDLE_VALUE) { return; @@ -496,18 +488,19 @@ void SysFileFindFiles(const std::filesystem::path& path, std::vector(FILE_ATTRIBUTE_DIRECTORY)) != 0u) { - SysFileFindFiles(std::filesystem::path(real_path) / file_name, out); + SysFileFindFiles(full_path, out); } else { sys_file_find_t r {}; - r.path_with_name = std::filesystem::path(real_path) / file_name; + r.path_with_name = full_path; r.size = (static_cast(data.nFileSizeHigh) << 32u) + static_cast(data.nFileSizeLow); r.last_access_time.is_invalid = false; @@ -515,7 +508,7 @@ void SysFileFindFiles(const std::filesystem::path& path, std::vector& out) { - std::string real_path = Common::ReplaceChar(Common::PathToGenericString(path), '\\', '/'); - if (!real_path.ends_with("/")) { - real_path += "/"; - } + const auto pattern = path / L"*"; - std::string pattern = real_path + "*"; - - HANDLE h = nullptr; - WIN32_FIND_DATAW data; - - auto wide_pattern = std::filesystem::path(pattern).wstring(); - h = FindFirstFileW(wide_pattern.c_str(), &data); + WIN32_FIND_DATAW data {}; + HANDLE h = FindFirstFileW(pattern.c_str(), &data); if (h == INVALID_HANDLE_VALUE) { return; @@ -549,7 +534,7 @@ void SysFileGetDents(const std::filesystem::path& path, std::vector(FILE_ATTRIBUTE_DIRECTORY)) == 0u); r.name = Common::PathToString(file_name); - out.push_back(r); + out.push_back(std::move(r)); } while (FindNextFileW(h, &data) != 0);