Ensure that sceIoOpen() fails on directories.

This commit is contained in:
Andrew Church 2014-09-04 18:03:28 +09:00 committed by Andrew Church
parent 2186892381
commit f976c309b4

View file

@ -218,6 +218,7 @@ bool DirectoryFileHandle::Open(std::string& basePath, std::string& fileName, Fil
hFile = open(fullName.c_str(), flags, 0666);
bool success = hFile != -1;
#endif
#if HOST_IS_CASE_SENSITIVE
@ -240,6 +241,17 @@ bool DirectoryFileHandle::Open(std::string& basePath, std::string& fileName, Fil
}
#endif
#ifndef _WIN32
if (success) {
struct stat st;
if (fstat(hFile, &st) == 0 && S_ISDIR(st.st_mode)) {
close(hFile);
errno = EISDIR;
success = false;
}
}
#endif
return success;
}