hide non-ROM files

This commit is contained in:
dborth 2010-07-12 06:10:00 +00:00
parent f757c5541d
commit a3a081f825

View File

@ -484,26 +484,56 @@ 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, "nes") != 0 && stricmp(p, "fds") != 0 &&
stricmp(p, "nsf") != 0 && stricmp(p, "unf") != 0 &&
stricmp(p, "nez") != 0 && stricmp(p, "unif") != 0 &&
stricmp(ext, "zip") != 0 && stricmp(ext, "7z") != 0)
continue; continue;
} }