From 6170379f59f4fb1bbfa1b19b4e35c062731dd525 Mon Sep 17 00:00:00 2001 From: Extrems Date: Fri, 9 Feb 2024 16:53:33 -0500 Subject: [PATCH] Handle EOVERFLOW --- gx/fileio/file_load.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/gx/fileio/file_load.c b/gx/fileio/file_load.c index 9f7ac4b..242b832 100644 --- a/gx/fileio/file_load.c +++ b/gx/fileio/file_load.c @@ -44,6 +44,7 @@ #include "filesel.h" #include "file_slot.h" +#include #include #ifdef HW_RVL #include @@ -231,11 +232,19 @@ int ParseDirectory(void) return -1; } - struct dirent *entry = readdir(dir); + struct dirent *entry = NULL; /* list entries */ - while ((entry != NULL)&& (nbfiles < MAXFILES)) + do { + errno = 0; + /* next entry */ + entry = readdir(dir); + if (entry == NULL) + { + continue; + } + /* filter entries */ if ((entry->d_name[0] != '.') && strncasecmp(".wav", &entry->d_name[strlen(entry->d_name) - 4], 4) @@ -250,10 +259,8 @@ int ParseDirectory(void) } nbfiles++; } - - /* next entry */ - entry = readdir(dir); } + while ((entry != NULL || errno == EOVERFLOW) && (nbfiles < MAXFILES)); /* close directory */ closedir(dir);