From 543530419fe5382d770686e406066ad6d620ec47 Mon Sep 17 00:00:00 2001 From: dborth Date: Fri, 21 Jan 2011 02:36:06 +0000 Subject: [PATCH] --- source/fileop.cpp | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/source/fileop.cpp b/source/fileop.cpp index 38efbbc..8b23c42 100644 --- a/source/fileop.cpp +++ b/source/fileop.cpp @@ -484,6 +484,7 @@ bool ParseDirEntries() return false; char *ext; + char path[MAXPATHLEN+1]; struct dirent *entry; struct stat filestat; @@ -499,20 +500,30 @@ 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, "nes") != 0 && stricmp(ext, "fds") != 0 && - stricmp(ext, "nsf") != 0 && stricmp(ext, "unf") != 0 && - stricmp(ext, "nez") != 0 && stricmp(ext, "unif") != 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, "nes") != 0 && stricmp(ext, "fds") != 0 && + stricmp(ext, "nsf") != 0 && stricmp(ext, "unf") != 0 && + stricmp(ext, "nez") != 0 && stricmp(ext, "unif") != 0 && + stricmp(ext, "zip") != 0 && stricmp(ext, "7z") != 0) + continue; + } } if(!AddBrowserEntry())