diff options
author | Max Horn | 2002-11-15 17:05:50 +0000 |
---|---|---|
committer | Max Horn | 2002-11-15 17:05:50 +0000 |
commit | e29c27ec27b875dcbc5ea38bf1199f2bef4a9041 (patch) | |
tree | f645629f1e6a411ee93591abe26884f4edf27ca4 | |
parent | 9294fda5662c6c6dab225508e75a3d67262d1ce3 (diff) | |
download | scummvm-rg350-e29c27ec27b875dcbc5ea38bf1199f2bef4a9041.tar.gz scummvm-rg350-e29c27ec27b875dcbc5ea38bf1199f2bef4a9041.tar.bz2 scummvm-rg350-e29c27ec27b875dcbc5ea38bf1199f2bef4a9041.zip |
use stat to detect directories -> should be POSIX compliant this time, and also work on Solaris
svn-id: r5568
-rw-r--r-- | backends/fs/posix/posix-fs.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/backends/fs/posix/posix-fs.cpp b/backends/fs/posix/posix-fs.cpp index 11301b8a9c..65e8c6bd86 100644 --- a/backends/fs/posix/posix-fs.cpp +++ b/backends/fs/posix/posix-fs.cpp @@ -25,6 +25,7 @@ #ifdef MACOSX #include <sys/types.h> #endif +#include <sys/stat.h> #include <dirent.h> /* @@ -86,6 +87,7 @@ POSIXFilesystemNode::POSIXFilesystemNode(const POSIXFilesystemNode *node) { FSList *POSIXFilesystemNode::listDir() const { assert(_isDirectory); DIR *dirp = opendir(_path.c_str()); + struct stat st; assert(dirp != 0); struct dirent *dp; @@ -99,13 +101,16 @@ FSList *POSIXFilesystemNode::listDir() const { POSIXFilesystemNode entry; entry._displayName = dp->d_name; - entry._isDirectory = (dp->d_type == DT_DIR); // TODO - add support for symlinks to dirs? + entry._path = _path; + entry._path += dp->d_name; + + if (stat(entry._path.c_str(), &st)) + continue; + entry._isDirectory = S_ISDIR(st.st_mode); // FIXME - skip any non-directories for now if (!entry._isDirectory) continue; - entry._path = _path; - entry._path += dp->d_name; if (entry._isDirectory) entry._path += "/"; myList->push_back(entry); |