[Scummvm-cvs-logs] SF.net SVN: scummvm: [22382] scummvm/trunk/backends/fs/posix/posix-fs.cpp
eriktorbjorn at users.sourceforge.net
eriktorbjorn at users.sourceforge.net
Sun May 7 21:49:01 CEST 2006
Revision: 22382
Author: eriktorbjorn
Date: 2006-05-07 21:48:40 -0700 (Sun, 07 May 2006)
ViewCVS: http://svn.sourceforge.net/scummvm/?rev=22382&view=rev
Log Message:
-----------
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.
Modified Paths:
--------------
scummvm/trunk/backends/fs/posix/posix-fs.cpp
Modified: scummvm/trunk/backends/fs/posix/posix-fs.cpp
===================================================================
--- scummvm/trunk/backends/fs/posix/posix-fs.cpp 2006-05-08 04:11:21 UTC (rev 22381)
+++ scummvm/trunk/backends/fs/posix/posix-fs.cpp 2006-05-08 04:48:40 UTC (rev 22382)
@@ -131,7 +131,7 @@
#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 @@
// 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);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list