hide non-ROM files

This commit is contained in:
dborth 2010-07-12 06:11:52 +00:00
parent edf81493b1
commit b11d28d5b4

View File

@ -483,32 +483,63 @@ void CreateAppPath(char * origpath)
free(path); free(path);
} }
static char *GetExt(char *file)
{
if(!file)
return NULL;
char *ext = strrchr(file,'.');
if(ext != NULL)
{
ext++;
int extlen = strlen(ext);
if(extlen > 5)
return NULL;
}
return ext;
}
bool ParseDirEntries() bool ParseDirEntries()
{ {
if(!dirIter) if(!dirIter)
return false; return false;
char filename[MAXPATHLEN]; char filename[MAXPATHLEN];
char *ext;
struct stat filestat; struct stat filestat;
int i, res; int i = 0;
int res;
for(i=0; i < 20; i++) while(i < 20)
{ {
res = dirnext(dirIter,filename,&filestat); res = dirnext(dirIter,filename,&filestat);
if(res != 0) if(res != 0)
break; break;
if(strcmp(filename,".") == 0) if(filename[0] == '.' && filename[1] != '.')
continue;
ext = GetExt(filename);
// don't show the file if it's not a valid ROM
if((filestat.st_mode & _IFDIR) == 0)
{ {
i--; if(ext == NULL)
continue;
if( stricmp(p, "agb") != 0 && stricmp(p, "gba") != 0 &&
stricmp(p, "bin") != 0 && stricmp(p, "elf") != 0 &&
stricmp(p, "mb") != 0 && stricmp(p, "dmg") != 0 &&
stricmp(p, "gb") != 0 && stricmp(p, "gbc") != 0 &&
stricmp(p, "cgb") != 0 && stricmp(p, "sgb") != 0 &&
stricmp(ext, "zip") != 0 && stricmp(ext, "7z") != 0)
continue; continue;
} }
if(!AddBrowserEntry()) if(!AddBrowserEntry())
{ {
i=0;
parseHalt = true; parseHalt = true;
break; break;
} }
@ -530,6 +561,7 @@ bool ParseDirEntries()
{ {
StripExt(browserList[browser.numEntries+i].displayname, browserList[browser.numEntries+i].filename); // hide file extension StripExt(browserList[browser.numEntries+i].displayname, browserList[browser.numEntries+i].filename); // hide file extension
} }
i++;
} }
// Sort the file list // Sort the file list