Last active
February 15, 2025 14:55
-
-
Save PeterTh/3b9b8be1aa4a9c87257b825dd4ea3567 to your computer and use it in GitHub Desktop.
Workaround for loading saves from other games on Steam Deck
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is part of the function that finds the path for the previous games' saves for importing | |
// ideally you should also cache the result if this is required more than once | |
using namespace fs = std::filesystem; | |
std::string path = ph3lib::os::commonFolder(ph3lib::os::CommonFolder::SavedGames) + "/Falcom/Kuro/"; | |
if (fs::exists(path)) { | |
return path; | |
} | |
// special handling for when running on the Steam Deck (or a Wine environment in general) | |
PH3LIB_INFO("Saves folder {} doesn't exist, maybe Proton?", path); | |
const auto winePrefix = getenv("WINEPREFIX"); | |
if (winePrefix) { | |
PH3LIB_INFO(" -> found wine prefix: {}", winePrefix); | |
if (!fs::exists(fs::path{ winePrefix })) { | |
PH3LIB_INFO(" -> doesn't exist"); | |
return path; | |
} | |
// prefix + path_to_c_mount + (winpath - "C:\") | |
path = ph3lib::utils::FilePath(winePrefix) + "/../../2138610/pfx/drive_c/" + path.substr(3); | |
PH3LIB_INFO(" -> checking: {}", path); | |
if (fs::exists(path)) { | |
PH3LIB_INFO(" -> success!"); | |
return path; | |
} | |
PH3LIB_INFO(" -> doesn't exist"); | |
} else { | |
PH3LIB_INFO("WINEPREFIX env var not found"); | |
} |
Right -- that's what ph3lib::os::commonFolder
does, but the example is a bit incomplete without that.
Heh, I figured it would. I posted my comment for the benefit of others who might stumble upon this gist.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For reference, the recommended way to obtain the path to the "Saved Games" directory is
SHGetKnownFolderPath
: