-Remove trailing separator when opening dirs if exist (windows doesn't like it)

-Support for opening dirs in windows
This commit is contained in:
georgemoralis 2025-05-22 11:26:11 +03:00
parent 786ad6f71e
commit 0289b99d69
3 changed files with 71 additions and 6 deletions

View file

@ -211,7 +211,15 @@ public:
IOFile out(path, FileAccessMode::Write);
return out.Write(data);
}
#ifdef _WIN32
std::filesystem::path RemoveTrailingSeparator(const std::filesystem::path& input) {
std::wstring str = input.native();
while (!str.empty() && (str.back() == L'\\' || str.back() == L'/')) {
str.pop_back();
}
return std::filesystem::path(str);
}
#endif
private:
std::filesystem::path file_path;
FileAccessMode file_access_mode{};
@ -222,5 +230,7 @@ private:
};
u64 GetDirectorySize(const std::filesystem::path& path);
#ifdef _WIN32
FILE* OpenDirAsFilePtr(const wchar_t* path, const wchar_t* mode, bool isDirectory);
#endif
} // namespace Common::FS