17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-08 05:10:41 +01:00

fix(app): a scenario failing as it loads goes back to the launcher too, the files of other cases looked for only off Windows

A scenario failing past its opening popped the loader mode and went on to pop it again and push the driver mode with the scenery half loaded; it goes back to the launcher as one that can't be opened. FileCased() goes through the folder only where the file system tells the case apart: on Windows a missing file was looked for in its whole folder for nothing, and a name outside the code page threw from the parser. The Discord thread sleeps a quarter of a second outside the driver mode, not to hold the closing up.
This commit is contained in:
maj00r
2026-11-03 21:53:52 +01:00
parent e230d7b902
commit ed0ff36a69
5 changed files with 15 additions and 3 deletions

View File

@@ -476,6 +476,12 @@ std::string FileCased(std::string const &Filename)
std::error_code error;
if (std::filesystem::exists(Filename, error))
return Filename;
#ifdef _WIN32
// the names there are found in any case already: no folder to go through for every file missing, nor names outside of the
// code page to throw on
return {};
#else
// only the name of the file itself, a folder named in another case isn't found
std::filesystem::path const path{Filename};
auto const directory{path.has_parent_path() ? path.parent_path() : std::filesystem::path{"."}};
auto const wanted{ToLower(path.filename().string())};
@@ -483,6 +489,7 @@ std::string FileCased(std::string const &Filename)
if (ToLower(entry->path().filename().string()) == wanted)
return path.has_parent_path() ? (directory / entry->path().filename()).string() : entry->path().filename().string();
return {};
#endif
}
std::pair<std::string, std::string> FileExists(std::vector<std::string> const &Names, std::vector<std::string> const &Extensions)

View File

@@ -218,7 +218,7 @@ template <> bool extract_value(bool &Variable, std::string const &Key, std::stri
bool FileExists(std::string const &Filename);
// the file as it's named on the disk when only the case of its name differs, as in the sceneries made on Windows; empty when
// there's none
// there's none. the folders have to be named in their case; on Windows, finding the names in any case itself, the file given or none
std::string FileCased(std::string const &Filename);
std::pair<std::string, std::string> FileExists(std::vector<std::string> const &Names, std::vector<std::string> const &Extensions);