1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-12-25 07:15:12 +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
if (dptr->d_type != DT_UNKNOWN && dptr->d_type != DT_LNK) {
isDir = dptr->d_type == DT_DIR;
isFile = dptr->d_type == DT_REG;
} else
#endif
{
@ -109,6 +110,7 @@ bool FileLister::browse(const string& path, bool clean)
continue;
}
isDir = S_ISDIR(st.st_mode);
isFile = S_ISREG(st.st_mode);
}
if (isDir) {
@ -116,7 +118,7 @@ bool FileLister::browse(const string& path, bool clean)
continue;
directorySet.insert(string(dptr->d_name));
} else {
} else if (isFile) {
if (!showFiles)
continue;