18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-21 03:54:57 +01:00

fix(files): data named in another case is found on Linux, folders included

The parser and the loaders lowercase every name they read, while the data
made on Windows has files and folders named in any case (scenery/Braniewo,
textures/siec_trakcyjna_ph/.../STS_*.tga, sounds/sip/Gorki.wav). FileCased
matched the file name only, so a folder in another case wasn't found.

- FileCased walks every part of the path on Linux, the folder listings kept
  by their lowercase and read again once the folder changed; Windows as it was
- FileExists finds the file in any case on Linux, and the variant with names
  and extensions gives back the name as it's on the disk, so textures,
  materials, sounds, station announcements and scripts open that name
- models, sound captions, timetables and nodebank previews open the file
  as it's named on the disk; the texture format is told by the extension in
  any case
This commit is contained in:
maj00r
2026-11-13 15:41:40 +01:00
parent 0371581049
commit d0a3694657
8 changed files with 157 additions and 26 deletions

View File

@@ -222,10 +222,11 @@ template <typename Type_> bool extract_value(Type_ &Variable, std::string const
template <> bool extract_value(bool &Variable, std::string const &Key, std::string const &Input, std::string const &Default);
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. the folders have to be named in their case; on Windows, finding the names in any case itself, the file given or none
// the file as it's named on the disk when only the case of its name or of its folders differs, as in the sceneries made on Windows;
// empty when there's none. on Windows, finding the names in any case itself, the file given or none
std::string FileCased(std::filesystem::path const &Filename);
// the first name with one of the extensions which has a file, in the order given, as the file is named on the disk
std::pair<std::string, std::string> FileExists(std::vector<std::string> const &Names, std::vector<std::string> const &Extensions);
// returns time of last modification for specified file