From 045a0597428f137e6f3adad0b0909b95c60f6dbd Mon Sep 17 00:00:00 2001 From: goeiecool9999 Date: Fri, 9 Sep 2022 16:10:12 +0200 Subject: [PATCH] fix for when file open is successful but the path isn't a file (#220) FSC and indirectly coreinit relies on FileStream open failing for directories --- src/Common/unix/FileStream_unix.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Common/unix/FileStream_unix.cpp b/src/Common/unix/FileStream_unix.cpp index b1e95ae9..08d2bc3d 100644 --- a/src/Common/unix/FileStream_unix.cpp +++ b/src/Common/unix/FileStream_unix.cpp @@ -198,6 +198,11 @@ FileStream::FileStream(const fs::path& path, bool isOpen, bool isWriteable) m_fileStream.open(path, std::ios_base::in | std::ios_base::out | std::ios_base::binary | std::ios_base::trunc); m_isValid = m_fileStream.is_open(); } + if(m_isValid && fs::is_directory(path)) + { + m_isValid = false; + m_fileStream.close(); + } } void FileStream::SyncReadWriteSeek(bool nextOpIsWrite)