From 2492aefb87060a63cc128c5d109bfe177dcee8a8 Mon Sep 17 00:00:00 2001 From: Shaun Inman Date: Tue, 21 Mar 2023 20:51:53 -0400 Subject: [PATCH] fixed: bare tag name folders are always empty --- src/minui/minui.c | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/src/minui/minui.c b/src/minui/minui.c index 77890f6..3851638 100644 --- a/src/minui/minui.c +++ b/src/minui/minui.c @@ -781,26 +781,27 @@ static Array* getEntries(char* path){ char collated_path[256]; strcpy(collated_path, path); char* tmp = strrchr(collated_path, '('); - if (tmp) { - tmp[1] = '\0'; // 1 because we want to keep the opening parenthesis to avoid collating "Game Boy Color" and "Game Boy Advance" into "Game Boy" - - DIR *dh = opendir(ROMS_PATH); - if (dh!=NULL) { - struct dirent *dp; - char full_path[256]; - sprintf(full_path, "%s/", ROMS_PATH); - tmp = full_path + strlen(full_path); - // while loop so we can collate paths, see above - while((dp = readdir(dh)) != NULL) { - if (hide(dp->d_name)) continue; - if (dp->d_type!=DT_DIR) continue; - strcpy(tmp, dp->d_name); - - if (!prefixMatch(collated_path, full_path)) continue; - addEntries(entries, full_path); - } - closedir(dh); + // 1 because we want to keep the opening parenthesis to avoid collating "Game Boy Color" and "Game Boy Advance" into "Game Boy" + // but conditional so we can continue to support a bare tag name as a folder name + if (tmp) tmp[1] = '\0'; + + DIR *dh = opendir(ROMS_PATH); + if (dh!=NULL) { + struct dirent *dp; + char full_path[256]; + sprintf(full_path, "%s/", ROMS_PATH); + tmp = full_path + strlen(full_path); + LOG_info("%s\n", full_path); + // while loop so we can collate paths, see above + while((dp = readdir(dh)) != NULL) { + if (hide(dp->d_name)) continue; + if (dp->d_type!=DT_DIR) continue; + strcpy(tmp, dp->d_name); + + if (!prefixMatch(collated_path, full_path)) continue; + addEntries(entries, full_path); } + closedir(dh); } } else addEntries(entries, path); // just a subfolder