diff options
author | Max Horn | 2006-04-10 19:26:40 +0000 |
---|---|---|
committer | Max Horn | 2006-04-10 19:26:40 +0000 |
commit | 8271273cb5ca8041b9d8e1ddd3b029ee2995800c (patch) | |
tree | 3d1875d89e2bf1e83d8c870e0233a83f3412d237 /backends/fs | |
parent | a06a28fa97f4c278166cfa83fac87977b3a0f864 (diff) | |
download | scummvm-rg350-8271273cb5ca8041b9d8e1ddd3b029ee2995800c.tar.gz scummvm-rg350-8271273cb5ca8041b9d8e1ddd3b029ee2995800c.tar.bz2 scummvm-rg350-8271273cb5ca8041b9d8e1ddd3b029ee2995800c.zip |
Fallback to using stat() if readdir returns DT_UNKNOWN (replacing the AMD64 hack)
svn-id: r21767
Diffstat (limited to 'backends/fs')
-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 |