all repos — mgba @ 15037950f0346f49e06d4a2643c16a69388d1611

mGBA Game Boy Advance Emulator

GUI: Sort file lists
Jeffrey Pfau jeffrey@endrift.com
Wed, 26 Aug 2015 21:48:56 -0700
commit

15037950f0346f49e06d4a2643c16a69388d1611

parent

d5697971a93a22ecc90a25e969fae05b91437617

1 files changed, 7 insertions(+), 0 deletions(-)

jump to
M src/util/gui/file-select.csrc/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; }