From b1e0effdb0d8c2ee1bf7a59e9d1a9bf1e3be1225 Mon Sep 17 00:00:00 2001 From: dborth Date: Fri, 21 Jan 2011 02:36:25 +0000 Subject: [PATCH] --- source/fileop.cpp | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/source/fileop.cpp b/source/fileop.cpp index a34a831..35e97bd 100644 --- a/source/fileop.cpp +++ b/source/fileop.cpp @@ -482,6 +482,7 @@ bool ParseDirEntries() return false; char *ext; + char path[MAXPATHLEN+1]; struct dirent *entry; struct stat filestat; @@ -497,22 +498,32 @@ bool ParseDirEntries() if(entry->d_name[0] == '.' && entry->d_name[1] != '.') continue; - ext = GetExt(entry->d_name); - stat(entry->d_name,&filestat); - - // don't show the file if it's not a valid ROM - if(parseFilter && (filestat.st_mode & _IFDIR) == 0) + if(strcmp(entry->d_name, "..") == 0) { - if(ext == NULL) + filestat.st_mode = _IFDIR; + } + else + { + ext = GetExt(entry->d_name); + snprintf(path, MAXPATHLEN, "%s%s", browser.dir, entry->d_name); + + if(stat(path, &filestat) < 0) continue; - if( stricmp(ext, "agb") != 0 && stricmp(ext, "gba") != 0 && - stricmp(ext, "bin") != 0 && stricmp(ext, "elf") != 0 && - stricmp(ext, "mb") != 0 && stricmp(ext, "dmg") != 0 && - stricmp(ext, "gb") != 0 && stricmp(ext, "gbc") != 0 && - stricmp(ext, "cgb") != 0 && stricmp(ext, "sgb") != 0 && - stricmp(ext, "zip") != 0 && stricmp(ext, "7z") != 0) - continue; + // don't show the file if it's not a valid ROM + if(parseFilter && (filestat.st_mode & _IFDIR) == 0) + { + if(ext == NULL) + continue; + + if( stricmp(ext, "agb") != 0 && stricmp(ext, "gba") != 0 && + stricmp(ext, "bin") != 0 && stricmp(ext, "elf") != 0 && + stricmp(ext, "mb") != 0 && stricmp(ext, "dmg") != 0 && + stricmp(ext, "gb") != 0 && stricmp(ext, "gbc") != 0 && + stricmp(ext, "cgb") != 0 && stricmp(ext, "sgb") != 0 && + stricmp(ext, "zip") != 0 && stricmp(ext, "7z") != 0) + continue; + } } if(!AddBrowserEntry())