diff options
author | Torbjörn Andersson | 2006-05-08 04:48:40 +0000 |
---|---|---|
committer | Torbjörn Andersson | 2006-05-08 04:48:40 +0000 |
commit | 30c0bd63bc416df36f97e7aff6182e19f34e7c00 (patch) | |
tree | 01b56ad104364b1f859203e38c9c558d7766e090 /backends/fs/posix | |
parent | e2c058551b4424d010d2c36dee1685e4b0946f92 (diff) | |
download | scummvm-rg350-30c0bd63bc416df36f97e7aff6182e19f34e7c00.tar.gz scummvm-rg350-30c0bd63bc416df36f97e7aff6182e19f34e7c00.tar.bz2 scummvm-rg350-30c0bd63bc416df36f97e7aff6182e19f34e7c00.zip |
Fixed bug #1483450. Apparently, S_ISDIR() is undefined if stat() fails. The
change to the POSIXFilesystemNode constructor is the one that matters to this
bug. The changes to listDir() are made from paranoia.
svn-id: r22382
Diffstat (limited to 'backends/fs/posix')
-rw-r--r-- | backends/fs/posix/posix-fs.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/backends/fs/posix/posix-fs.cpp b/backends/fs/posix/posix-fs.cpp index b9278fbb00..ea874c9d0e 100644 --- a/backends/fs/posix/posix-fs.cpp +++ b/backends/fs/posix/posix-fs.cpp @@ -131,7 +131,7 @@ POSIXFilesystemNode::POSIXFilesystemNode(const String &p, bool verify) { #else struct stat st; _isValid = (0 == stat(_path.c_str(), &st)); - _isDirectory = S_ISDIR(st.st_mode); + _isDirectory = _isValid ? S_ISDIR(st.st_mode) : false; #endif } } @@ -166,19 +166,21 @@ bool POSIXFilesystemNode::listDir(AbstractFSList &myList, ListMode mode) const { // add this #elif case, which tries to use stat() instead. struct stat st; entry._isValid = (0 == stat(entry._path.c_str(), &st)); - entry._isDirectory = S_ISDIR(st.st_mode); + entry._isDirectory = entry._isValid ? S_ISDIR(st.st_mode) : false; #else if (dp->d_type == DT_UNKNOWN) { // Fall back to stat() struct stat st; entry._isValid = (0 == stat(entry._path.c_str(), &st)); - entry._isDirectory = S_ISDIR(st.st_mode); + entry._isDirectory = entry._isValid ? S_ISDIR(st.st_mode) : false; } else { 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); + if (stat(entry._path.c_str(), &st) == 0) + entry._isDirectory = S_ISDIR(st.st_mode); + else + entry._isDirectory = false; } else { entry._isDirectory = (dp->d_type == DT_DIR); } |