diff options
Diffstat (limited to 'backends/fs/posix')
-rw-r--r-- | backends/fs/posix/posix-fs.cpp | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/backends/fs/posix/posix-fs.cpp b/backends/fs/posix/posix-fs.cpp index 9ce7a85990..e5c8c71ae3 100644 --- a/backends/fs/posix/posix-fs.cpp +++ b/backends/fs/posix/posix-fs.cpp @@ -137,12 +137,7 @@ FSList POSIXFilesystemNode::listDir(ListMode mode) const { #ifdef __DC__ entry._isDirectory = dp->d_size < 0; -#elif defined(SYSTEM_NOT_SUPPORTING_D_TYPE) || defined(__x86_64__) - // HACK: on debian/unstable (and gentoo it seems) running on amd64 the d_type field - // is always 0/DT_UNKNOWN so use this also on amd64 systems maybe check this in - // the configure script when running on an amd64 instead of forcing it for all amd64 - // systems. It seems to work on Fedora though. - +#elif defined(SYSTEM_NOT_SUPPORTING_D_TYPE) // TODO: d_type is not part of POSIX, so it might not be supported // on some of our targets. For those systems where it isn't supported, // add this #elif case, which tries to use stat() instead. @@ -150,13 +145,20 @@ FSList POSIXFilesystemNode::listDir(ListMode mode) const { entry._isValid = (0 == stat(entry._path.c_str(), &st)); entry._isDirectory = S_ISDIR(st.st_mode); #else - entry._isValid = (dp->d_type == DT_DIR) || (dp->d_type == DT_REG) || (dp->d_type == DT_LNK); - if (dp->d_type == DT_LNK) { + if (dp->d_type == DT_UNKNOWN) { + // Fall back to stat() struct stat st; - stat(entry._path.c_str(), &st); + entry._isValid = (0 == stat(entry._path.c_str(), &st)); entry._isDirectory = S_ISDIR(st.st_mode); } else { - entry._isDirectory = (dp->d_type == DT_DIR); + entry._isValid = (dp->d_type == DT_DIR) || (dp->d_type == DT_REG) || (dp->d_type == DT_LNK); + if (dp->d_type == DT_LNK) { + struct stat st; + stat(entry._path.c_str(), &st); + entry._isDirectory = S_ISDIR(st.st_mode); + } else { + entry._isDirectory = (dp->d_type == DT_DIR); + } } #endif |