From 8271273cb5ca8041b9d8e1ddd3b029ee2995800c Mon Sep 17 00:00:00 2001 From: Max Horn Date: Mon, 10 Apr 2006 19:26:40 +0000 Subject: Fallback to using stat() if readdir returns DT_UNKNOWN (replacing the AMD64 hack) svn-id: r21767 --- backends/fs/posix/posix-fs.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'backends/fs/posix') 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 -- cgit v1.2.3