From c7a5b874f196bae4364fce17620f4387db418bf9 Mon Sep 17 00:00:00 2001 From: Maarten ter Huurne Date: Wed, 20 Aug 2014 13:09:49 +0200 Subject: [PATCH] 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. --- src/filelister.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/filelister.cpp b/src/filelister.cpp index a7a7c49..36d3110 100644 --- a/src/filelister.cpp +++ b/src/filelister.cpp @@ -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;