Skip to content

Commit

Permalink
increase max filenames and filename buffer, sort filenames
Browse files Browse the repository at this point in the history
  • Loading branch information
RSDuck committed May 27, 2018
1 parent d3ce576 commit 9a5d4e1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -47,7 +47,7 @@ CFLAGS := -g -Wall -Ofast -ffunction-sections \
$(ARCH) $(DEFINES)

CFLAGS += $(INCLUDE) -D__SWITCH__ -DTILED_RENDERING -DBRANCHLESS_GBA_GFX \
-DUSE_FRAME_SKIP -DNXLINK_STDIO#-DTHREADED_RENDERER
-DUSE_FRAME_SKIP# -DNXLINK_STDIO#-DTHREADED_RENDERER

CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11

Expand Down
4 changes: 2 additions & 2 deletions source/switch/ui.cpp
Expand Up @@ -189,8 +189,8 @@ struct Setting {
bool meta;
};

#define FILENAMEBUFFER_SIZE (1024 * 20) // 20kb
#define FILENAMES_COUNT_MAX 1024
#define FILENAMEBUFFER_SIZE (1024 * 32) // 32kb
#define FILENAMES_COUNT_MAX 2048

#define SETTINGS_MAX (128)

Expand Down
6 changes: 6 additions & 0 deletions source/switch/util.cpp
@@ -1,5 +1,6 @@
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/dirent.h>

Expand All @@ -9,6 +10,8 @@ struct alphabetize {
inline bool operator()(char* a, char* b) { return strcasecmp(a, b) < 0; }
};

static int sortAlpha(const void* a, const void* b) { return strcasecmp(*((const char**)a), *((const char**)b)); }

bool isDirectory(char* path) {
DIR* dir = opendir(path);
if (!dir) {
Expand Down Expand Up @@ -58,6 +61,9 @@ void getDirectoryContents(char* filenameBuffer, char** filenames, int* filenames

closedir(dir);
}

qsort(filenames + 1, (*filenamesCount) - 1, // ".." should stay at the to
sizeof(char*), &sortAlpha);
}

void strcpy_safe(char* dst, const char* src, unsigned src_length) {
Expand Down

0 comments on commit 9a5d4e1

Please sign in to comment.