mirror of
https://github.com/libretro/scummvm.git
synced 2025-03-02 16:31:01 +00:00
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
This commit is contained in:
parent
e2c058551b
commit
30c0bd63bc
@ -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);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user