18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-20 06:55:02 +01:00

fix(files): the banks keep the names asked for, only the opening takes the case of the disk

The textures, materials and sounds are kept by the names they're asked for.
Given back as named on the disk, a file in another case missed the bank and
was loaded again on every request.

- FileExists with names and extensions finds the file in any case but gives
  back the name asked for; FileOnDisk gives the file to open, used where
  textures, sounds and scripts are opened
- FileExists of a single name is a plain check again, the places checking
  it and opening the same name stay as they were
- the texture format is told by the extension asked for again
- a folder changed shortly before it was read is read again for a name
  missing from it, the time of a change being as coarse as the clock of the
  file system; a listing cut short isn't kept
This commit is contained in:
maj00r
2026-11-13 15:47:52 +01:00
parent d0a3694657
commit afbc84c6bc
6 changed files with 55 additions and 47 deletions

View File

@@ -586,28 +586,28 @@ TEST_CASE("utilities: a file is found in folders named in another case, the way
// every part of the path in lowercase: the file as it's on the disk where the case matters, the name given where it doesn't
auto const timetable{FileCased(folder.path("scenery/braniewo/rozklady/os91121.txt"))};
REQUIRE_FALSE(timetable.empty());
CHECK(FileExists(timetable));
CHECK(std::filesystem::exists(timetable));
CHECK(ToLower(timetable) == ToLower(folder.path("Scenery/Braniewo/rozklady/Os91121.txt")));
CHECK(FileExists(folder.path("scenery/braniewo/rozklady/os91121.txt")));
CHECK(FileOnDisk(folder.path("scenery/braniewo/rozklady/os91121.txt")) == timetable);
// the folders written the Windows way as well
CHECK_FALSE(FileCased(folder.path() + "scenery\\braniewo\\rozklady\\os91121.txt").empty());
// a folder missing in any case
CHECK(FileCased(folder.path("scenery/nowhere/rozklady/os91121.txt")).empty());
CHECK_FALSE(FileExists(folder.path("scenery/nowhere/rozklady/os91121.txt")));
CHECK(FileOnDisk(folder.path("scenery/nowhere/rozklady/os91121.txt")) == folder.path("scenery/nowhere/rozklady/os91121.txt"));
// among names and extensions: given back as named on the disk, so it's opened by that name, the extension too
// among names and extensions: found in any case, given back as named, the name being the key of the banks
auto const texture{FileExists(std::vector<std::string>{folder.path("textures/tabl/l101-2m")}, std::vector<std::string>{".dds", ".bmp"})};
REQUIRE_FALSE(texture.first.empty());
CHECK(ToLower(texture.second) == ".bmp");
CHECK(FileExists(texture.first + texture.second));
CHECK(ToLower(texture.first) == ToLower(folder.path("Textures/Tabl/L101-2m")));
CHECK(texture.first == folder.path("textures/tabl/l101-2m"));
CHECK(texture.second == ".bmp");
CHECK(std::filesystem::exists(FileOnDisk(texture.first + texture.second)));
// a file written after the folder was gone through is found as well
CHECK(FileCased(folder.path("textures/tabl/l7-2m.bmp")).empty());
folder.write("Textures/Tabl/L7-2m.bmp", "x");
auto const added{FileCased(folder.path("textures/tabl/l7-2m.bmp"))};
REQUIRE_FALSE(added.empty());
CHECK(FileExists(added));
CHECK(std::filesystem::exists(added));
}
TEST_CASE("utilities: the time a file was changed is given, zero for a file which isn't there") {