mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-20 20:54:59 +01:00
fix(files): terrain files named in another case are found on Linux
The terrain directive names .txtf/.btf files in lowercase, as the parser gives every token. The name is now taken as it is on disk, from the text file first, so the binary file is made next to the text and the editor's references and layers keep one name.
This commit is contained in:
@@ -692,6 +692,19 @@ std::string FileOnDisk(std::string const &Filename)
|
||||
return cased.empty() ? Filename : cased;
|
||||
}
|
||||
|
||||
std::string FileStemOnDisk(std::string const &Folder, std::string const &Name, std::vector<std::string> const &Extensions)
|
||||
{
|
||||
for (auto const &extension : Extensions)
|
||||
{
|
||||
auto const cased{FileCased(Folder + Name + extension)};
|
||||
if (cased.size() > Folder.size() + extension.size() && cased.starts_with(Folder) && cased.ends_with(extension))
|
||||
{
|
||||
return cased.substr(Folder.size(), cased.size() - Folder.size() - extension.size());
|
||||
}
|
||||
}
|
||||
return Name;
|
||||
}
|
||||
|
||||
std::pair<std::string, std::string> FileExists(std::vector<std::string> const &Names, std::vector<std::string> const &Extensions)
|
||||
{
|
||||
|
||||
|
||||
@@ -227,6 +227,9 @@ bool FileExists(std::string const &Filename);
|
||||
std::string FileCased(std::filesystem::path const &Filename);
|
||||
// the file to open: as it's named on the disk, the name given when there's none
|
||||
std::string FileOnDisk(std::string const &Filename);
|
||||
// the name (relative to the folder, without extension) as it's named on the disk with the first of the extensions it has a file with,
|
||||
// found in any case; the name given when there's none
|
||||
std::string FileStemOnDisk(std::string const &Folder, std::string const &Name, std::vector<std::string> const &Extensions);
|
||||
|
||||
// the first name with one of the extensions which has a file in any case, in the order given; given back as named here, the file
|
||||
// is opened by FileOnDisk()
|
||||
|
||||
Reference in New Issue
Block a user