GUI: Sort file lists
Jeffrey Pfau jeffrey@endrift.com
Wed, 26 Aug 2015 21:48:56 -0700
1 files changed,
7 insertions(+),
0 deletions(-)
jump to
M
src/util/gui/file-select.c
→
src/util/gui/file-select.c
@@ -9,6 +9,8 @@ #include "util/gui/font.h"
#include "util/vector.h" #include "util/vfs.h" +#include <stdlib.h> + DECLARE_VECTOR(FileList, char*); DEFINE_VECTOR(FileList, char*);@@ -38,6 +40,10 @@ if (end[1]) {
return; } // TODO: What if there was a trailing slash? +} + +static int _strpcmp(const void* a, const void* b) { + return strcmp(*(const char**) a, *(const char**) b); } static bool _refreshDirectory(const struct GUIParams* params, const char* currentPath, struct FileList* currentFiles, bool (*filter)(struct VFile*)) {@@ -76,6 +82,7 @@ *FileListAppend(currentFiles) = strdup(name);
} } dir->close(dir); + qsort(FileListGetPointer(currentFiles, 1), FileListSize(currentFiles) - 1, sizeof(char*), _strpcmp); return true; }