mirror of
https://github.com/daveallie/crosspoint-reader.git
synced 2025-12-16 22:27:42 +03:00
Sort directories first in file picker
This commit is contained in:
parent
9fa697ae0c
commit
c715c18bf7
@ -3,8 +3,10 @@
|
||||
#include <EpdRenderer.h>
|
||||
#include <SD.h>
|
||||
|
||||
void caseInsensitiveSort(std::vector<std::string>& strs) {
|
||||
void sortFileList(std::vector<std::string>& strs) {
|
||||
std::sort(begin(strs), end(strs), [](const std::string& str1, const std::string& str2) {
|
||||
if (str1.back() == '/' && str2.back() != '/') return true;
|
||||
if (str1.back() != '/' && str2.back() == '/') return false;
|
||||
return lexicographical_compare(
|
||||
begin(str1), end(str1), begin(str2), end(str2),
|
||||
[](const char& char1, const char& char2) { return tolower(char1) < tolower(char2); });
|
||||
@ -35,7 +37,7 @@ void FileSelectionScreen::loadFiles() {
|
||||
file.close();
|
||||
}
|
||||
root.close();
|
||||
caseInsensitiveSort(files);
|
||||
sortFileList(files);
|
||||
}
|
||||
|
||||
void FileSelectionScreen::onEnter() {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user