mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-08 14:59:43 +01:00
Merge branch 'master' into feat/renderers-cleanup
This commit is contained in:
@@ -350,8 +350,11 @@ void win1250_to_ascii(std::string &Input)
|
||||
|
||||
std::string win1250_to_utf8(const std::string &Input)
|
||||
{
|
||||
std::unordered_map<char, std::string> const charmap{{165, "Ą"}, {198, "Ć"}, {202, "Ę"}, {163, "Ł"}, {209, "Ń"}, {211, "Ó"}, {140, "Ś"}, {143, "Ź"}, {175, "Ż"},
|
||||
{185, "ą"}, {230, "ć"}, {234, "ę"}, {179, "ł"}, {241, "ń"}, {243, "ó"}, {156, "ś"}, {159, "ź"}, {191, "ż"}};
|
||||
// the utf-8 sequences written as bytes: the file has a byte order mark and the build doesn't give the compiler /utf-8, so letters
|
||||
// written as letters would end up in the program in windows-1250, the same as the input
|
||||
static std::unordered_map<char, std::string> const charmap{{'\xA5', "\xC4\x84"}, {'\xC6', "\xC4\x86"}, {'\xCA', "\xC4\x98"}, {'\xA3', "\xC5\x81"}, {'\xD1', "\xC5\x83"}, {'\xD3', "\xC3\x93"},
|
||||
{'\x8C', "\xC5\x9A"}, {'\x8F', "\xC5\xB9"}, {'\xAF', "\xC5\xBB"}, {'\xB9', "\xC4\x85"}, {'\xE6', "\xC4\x87"}, {'\xEA', "\xC4\x99"},
|
||||
{'\xB3', "\xC5\x82"}, {'\xF1', "\xC5\x84"}, {'\xF3', "\xC3\xB3"}, {'\x9C', "\xC5\x9B"}, {'\x9F', "\xC5\xBA"}, {'\xBF', "\xC5\xBC"}};
|
||||
std::string output;
|
||||
std::unordered_map<char, std::string>::const_iterator lookup;
|
||||
for (auto &input : Input)
|
||||
@@ -504,18 +507,24 @@ bool FileExists(std::string const &Filename)
|
||||
return std::filesystem::exists(Filename);
|
||||
}
|
||||
|
||||
std::string FileCased(std::string const &Filename)
|
||||
std::string FileCased(std::filesystem::path const &Filename)
|
||||
{
|
||||
std::error_code error;
|
||||
if (std::filesystem::exists(Filename, error))
|
||||
return Filename;
|
||||
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())};
|
||||
return Filename.string();
|
||||
#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
|
||||
auto const directory{Filename.has_parent_path() ? Filename.parent_path() : std::filesystem::path{"."}};
|
||||
auto const wanted{ToLower(Filename.filename().string())};
|
||||
for (std::filesystem::directory_iterator entry{directory, error}, end; entry != end; entry.increment(error))
|
||||
if (ToLower(entry->path().filename().string()) == wanted)
|
||||
return path.has_parent_path() ? (directory / entry->path().filename()).string() : entry->path().filename().string();
|
||||
return Filename.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)
|
||||
|
||||
Reference in New Issue
Block a user