From 2d1694be67b8c62aff5d7242063052b5058a2abd Mon Sep 17 00:00:00 2001 From: sorgelig Date: Wed, 15 Jan 2020 17:24:32 +0800 Subject: [PATCH] arcade: pick most recent rbf if several are present. --- support/arcade/romutils.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/support/arcade/romutils.cpp b/support/arcade/romutils.cpp index 01a4dfa..711ffe3 100644 --- a/support/arcade/romutils.cpp +++ b/support/arcade/romutils.cpp @@ -838,37 +838,43 @@ static const char *get_rbf(const char *xml) return NULL; } - int found = 0; int len; + static char lastfound[256] = {}; while ((entry = readdir(dir)) != NULL) { if (entry->d_type != DT_DIR) { - char newstring[kBigTextSize]; + static char newstring[kBigTextSize]; //printf("entry name: %s\n",entry->d_name); snprintf(newstring, kBigTextSize, "Arcade-%s", rbfname); len = strlen(newstring); if (!strncasecmp(newstring, entry->d_name, len) && (entry->d_name[len] == '.' || entry->d_name[len] == '_')) { - found = 1; - break; + if (!lastfound[0] || strcmp(lastfound, entry->d_name) < 0) + { + printf("*** %s\n", entry->d_name); + strcpy(lastfound, entry->d_name); + } } snprintf(newstring, kBigTextSize, "%s", rbfname); len = strlen(newstring); if (!strncasecmp(newstring, entry->d_name, len) && (entry->d_name[len] == '.' || entry->d_name[len] == '_')) { - found = 1; - break; + if (!lastfound[0] || strcmp(lastfound, entry->d_name) < 0) + { + printf("*** %s\n", entry->d_name); + strcpy(lastfound, entry->d_name); + } } } } - if (found) sprintf(rbfname, "%s/%s", dirname, entry->d_name); + if (lastfound[0]) sprintf(rbfname, "%s/%s", dirname, lastfound); closedir(dir); - return found ? rbfname : NULL; + return lastfound[0] ? rbfname : NULL; } int arcade_load(const char *xml)