1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-11-22 12:30:18 +02:00

Don't assume that all non-directories are regular files

Other types are not very likely, but if we do encounter them it is best
to just skip them.
This commit is contained in:
Maarten ter Huurne 2014-08-20 13:09:49 +02:00
parent 3eb3a8ed7a
commit c7a5b874f1

View File

@ -94,10 +94,11 @@ bool FileLister::browse(const string& path, bool clean)
} }
} }
bool isDir; bool isDir, isFile;
#ifdef _DIRENT_HAVE_D_TYPE #ifdef _DIRENT_HAVE_D_TYPE
if (dptr->d_type != DT_UNKNOWN && dptr->d_type != DT_LNK) { if (dptr->d_type != DT_UNKNOWN && dptr->d_type != DT_LNK) {
isDir = dptr->d_type == DT_DIR; isDir = dptr->d_type == DT_DIR;
isFile = dptr->d_type == DT_REG;
} else } else
#endif #endif
{ {
@ -109,6 +110,7 @@ bool FileLister::browse(const string& path, bool clean)
continue; continue;
} }
isDir = S_ISDIR(st.st_mode); isDir = S_ISDIR(st.st_mode);
isFile = S_ISREG(st.st_mode);
} }
if (isDir) { if (isDir) {
@ -116,7 +118,7 @@ bool FileLister::browse(const string& path, bool clean)
continue; continue;
directorySet.insert(string(dptr->d_name)); directorySet.insert(string(dptr->d_name));
} else { } else if (isFile) {
if (!showFiles) if (!showFiles)
continue; continue;