Fix #12648: Ensure all uses of std::filesystem::path use native encoding. (#12650)

std::filesystem::path does not expect UTF-8 strings, so they must be converted to native format first (and back to utf-8 after.)
This commit is contained in:
Peter Nelson
2024-06-09 10:23:47 +01:00
committed by GitHub
parent fce9361bf2
commit b4b2fad8e0
6 changed files with 14 additions and 14 deletions

View File

@@ -578,7 +578,7 @@ int openttd_main(std::span<char * const> arguments)
if (mgo.opt != nullptr) {
_file_to_saveload.name = mgo.opt;
std::string extension = std::filesystem::path(_file_to_saveload.name).extension().string();
std::string extension = FS2OTTD(std::filesystem::path(OTTD2FS(_file_to_saveload.name)).extension());
auto [ft, _] = FiosGetSavegameListCallback(SLO_LOAD, _file_to_saveload.name, extension);
if (ft == FIOS_TYPE_INVALID) {
std::tie(ft, _) = FiosGetScenarioListCallback(SLO_LOAD, _file_to_saveload.name, extension);
@@ -612,7 +612,7 @@ int openttd_main(std::span<char * const> arguments)
return ret;
}
std::string extension = std::filesystem::path(mgo.opt).extension().string();
std::string extension = FS2OTTD(std::filesystem::path(OTTD2FS(mgo.opt)).extension());
auto [_, title] = FiosGetSavegameListCallback(SLO_LOAD, mgo.opt, extension);
_load_check_data.Clear();