From f976c309b4a5e8b16e759f236304a5baaa388c8a Mon Sep 17 00:00:00 2001 From: Andrew Church Date: Thu, 4 Sep 2014 18:03:28 +0900 Subject: [PATCH] Ensure that sceIoOpen() fails on directories. --- Core/FileSystems/DirectoryFileSystem.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Core/FileSystems/DirectoryFileSystem.cpp b/Core/FileSystems/DirectoryFileSystem.cpp index c0799dcd73..4c0fd6f542 100644 --- a/Core/FileSystems/DirectoryFileSystem.cpp +++ b/Core/FileSystems/DirectoryFileSystem.cpp @@ -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; }