mirror of
https://github.com/Huntereb/Awoo-Installer
synced 2025-02-17 04:08:23 +00:00
Sort files in file browser properly
This commit is contained in:
parent
4ac0308063
commit
98a1d58a4d
1 changed files with 12 additions and 2 deletions
|
@ -50,6 +50,16 @@ namespace inst::util {
|
|||
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) {
|
||||
return std::lexicographical_compare(a.begin(), a.end() , b.begin() ,b.end() , caseInsensitiveLess());
|
||||
}
|
||||
|
||||
std::vector<std::filesystem::path> getDirectoryFiles(const std::string & dir, const std::vector<std::string> & extensions) {
|
||||
std::vector<std::filesystem::path> files;
|
||||
for(auto & p: std::filesystem::directory_iterator(dir))
|
||||
|
@ -64,7 +74,7 @@ namespace inst::util {
|
|||
}
|
||||
}
|
||||
}
|
||||
std::sort(files.begin(), files.end());
|
||||
std::sort(files.begin(), files.end(), ignoreCaseCompare);
|
||||
return files;
|
||||
}
|
||||
|
||||
|
@ -77,7 +87,7 @@ namespace inst::util {
|
|||
files.push_back(p.path());
|
||||
}
|
||||
}
|
||||
std::sort(files.begin(), files.end());
|
||||
std::sort(files.begin(), files.end(), ignoreCaseCompare);
|
||||
return files;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue