use lambda for file sorting

This commit is contained in:
HookedBehemoth 2022-12-15 16:22:42 +01:00
parent 32fe03aac3
commit 975577fe81

View file

@ -52,14 +52,12 @@ namespace inst::util {
splExit(); splExit();
} }
struct caseInsensitiveLess : public std::binary_function< char,char,bool > {
bool operator () (char x, char y) const {
return toupper(static_cast< unsigned char >(x)) < toupper(static_cast< unsigned char >(y));
}
};
bool ignoreCaseCompare(const std::string &a, const std::string &b) { bool ignoreCaseCompare(const std::string &a, const std::string &b) {
return std::lexicographical_compare(a.begin(), a.end() , b.begin() ,b.end() , caseInsensitiveLess()); const auto case_insensitive_less = [](char x, char y) {
return toupper(static_cast<unsigned char>(x)) < toupper(static_cast<unsigned char>(y));
};
return std::lexicographical_compare(a.begin(), a.end(), b.begin(), b.end(), case_insensitive_less);
} }
std::vector<std::filesystem::path> getDirectoryFiles(const std::string & dir, const std::vector<std::string> & extensions) { std::vector<std::filesystem::path> getDirectoryFiles(const std::string & dir, const std::vector<std::string> & extensions) {