FIx detection of drive letter in windows path, use utf-8 for path #2

This commit is contained in:
Ondrej Novak 2025-04-30 23:00:46 +02:00
parent 3152a44d35
commit 54d7d22734
3 changed files with 40 additions and 18 deletions

View file

@ -15,13 +15,17 @@ std::string getSavedGamesDirectory() {
PWSTR path = nullptr;
if (SUCCEEDED(SHGetKnownFolderPath(FOLDERID_SavedGames, 0, NULL, &path))) {
fs::path savedGamesPath(path);
CoTaskMemFree(path);
return (savedGamesPath / SAVEGAME_FOLDERNAME).string();
CoTaskMemFree(path);
// Převod na UTF-8 std::string
std::u8string utf8 = (savedGamesPath / SAVEGAME_FOLDERNAME).u8string();
return std::string(reinterpret_cast<const char*>(utf8.data()), utf8.size());
} else {
display_error("Failed to retrieve FOLDEROD_SavedGames");
display_error("Failed to retrieve FOLDERID_SavedGames");
abort();
}
}
const char *get_default_savegame_directory() {
static std::string dir = getSavedGamesDirectory();