fixed: bare tag name folders are always empty

This commit is contained in:
Shaun Inman 2023-03-21 20:51:53 -04:00
parent 0f75041c09
commit 2492aefb87

View file

@ -781,26 +781,27 @@ static Array* getEntries(char* path){
char collated_path[256]; char collated_path[256];
strcpy(collated_path, path); strcpy(collated_path, path);
char* tmp = strrchr(collated_path, '('); char* tmp = strrchr(collated_path, '(');
if (tmp) { // 1 because we want to keep the opening parenthesis to avoid collating "Game Boy Color" and "Game Boy Advance" into "Game Boy"
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" // 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) { DIR *dh = opendir(ROMS_PATH);
struct dirent *dp; if (dh!=NULL) {
char full_path[256]; struct dirent *dp;
sprintf(full_path, "%s/", ROMS_PATH); char full_path[256];
tmp = full_path + strlen(full_path); sprintf(full_path, "%s/", ROMS_PATH);
// while loop so we can collate paths, see above tmp = full_path + strlen(full_path);
while((dp = readdir(dh)) != NULL) { LOG_info("%s\n", full_path);
if (hide(dp->d_name)) continue; // while loop so we can collate paths, see above
if (dp->d_type!=DT_DIR) continue; while((dp = readdir(dh)) != NULL) {
strcpy(tmp, dp->d_name); if (hide(dp->d_name)) continue;
if (dp->d_type!=DT_DIR) continue;
if (!prefixMatch(collated_path, full_path)) continue; strcpy(tmp, dp->d_name);
addEntries(entries, full_path);
} if (!prefixMatch(collated_path, full_path)) continue;
closedir(dh); addEntries(entries, full_path);
} }
closedir(dh);
} }
} }
else addEntries(entries, path); // just a subfolder else addEntries(entries, path); // just a subfolder