Skip to content

Commit 9a5d4e1

Browse files
committed
increase max filenames and filename buffer, sort filenames
1 parent d3ce576 commit 9a5d4e1

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ CFLAGS := -g -Wall -Ofast -ffunction-sections \
4747
$(ARCH) $(DEFINES)
4848

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

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

source/switch/ui.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,8 @@ struct Setting {
189189
bool meta;
190190
};
191191

192-
#define FILENAMEBUFFER_SIZE (1024 * 20) // 20kb
193-
#define FILENAMES_COUNT_MAX 1024
192+
#define FILENAMEBUFFER_SIZE (1024 * 32) // 32kb
193+
#define FILENAMES_COUNT_MAX 2048
194194

195195
#define SETTINGS_MAX (128)
196196

source/switch/util.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include <algorithm>
22
#include <stdio.h>
3+
#include <stdlib.h>
34
#include <string.h>
45
#include <sys/dirent.h>
56

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

13+
static int sortAlpha(const void* a, const void* b) { return strcasecmp(*((const char**)a), *((const char**)b)); }
14+
1215
bool isDirectory(char* path) {
1316
DIR* dir = opendir(path);
1417
if (!dir) {
@@ -58,6 +61,9 @@ void getDirectoryContents(char* filenameBuffer, char** filenames, int* filenames
5861

5962
closedir(dir);
6063
}
64+
65+
qsort(filenames + 1, (*filenamesCount) - 1, // ".." should stay at the to
66+
sizeof(char*), &sortAlpha);
6167
}
6268

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

0 commit comments

Comments
 (0)