Fix too menu entries in dir crashing GM9

... happened when there where more than 1024 entries.
This commit is contained in:
d0k3 2018-03-15 00:57:41 +01:00
parent 6a0391bb86
commit 02f5abb877

View File

@ -142,12 +142,12 @@ bool GetDirContentsWorker(DirStruct* contents, char* fpath, int fnsize, const ch
entry->size = fno.fsize;
}
entry->marked = 0;
if (contents->n_entries >= MAX_DIR_ENTRIES) {
ret = true; // Too many entries, still okay
if (!recursive || (entry->type != T_DIR)) {
if (++(contents->n_entries) >= MAX_DIR_ENTRIES) {
ret = true; // Too many entries, still okay if we stop here
break;
}
if (!recursive || (entry->type != T_DIR))
contents->n_entries++;
}
}
if (recursive && (fno.fattrib & AM_DIR)) {
if (!GetDirContentsWorker(contents, fpath, fnsize, pattern, recursive))