From 467b3e6bafdeeea57c8150d1373a5781d0601a46 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Sun, 14 Dec 2014 13:16:21 +0100 Subject: [PATCH] DiscIO: Clear error status when reading file --- Source/Core/DiscIO/CISOBlob.cpp | 3 +++ Source/Core/DiscIO/FileBlob.cpp | 11 +++++++++-- Source/Core/DiscIO/WbfsBlob.cpp | 6 +++++- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/Source/Core/DiscIO/CISOBlob.cpp b/Source/Core/DiscIO/CISOBlob.cpp index 23e1bb797a..e92b3b5178 100644 --- a/Source/Core/DiscIO/CISOBlob.cpp +++ b/Source/Core/DiscIO/CISOBlob.cpp @@ -66,7 +66,10 @@ bool CISOFileReader::Read(u64 offset, u64 nbytes, u8* out_ptr) u64 const file_off = CISO_HEADER_SIZE + m_ciso_map[block] * (u64)m_block_size + data_offset; if (!(m_file.Seek(file_off, SEEK_SET) && m_file.ReadArray(out_ptr, bytes_to_read))) + { + m_file.Clear(); return false; + } } else { diff --git a/Source/Core/DiscIO/FileBlob.cpp b/Source/Core/DiscIO/FileBlob.cpp index d7c4467738..9cf14cb0b4 100644 --- a/Source/Core/DiscIO/FileBlob.cpp +++ b/Source/Core/DiscIO/FileBlob.cpp @@ -25,8 +25,15 @@ PlainFileReader* PlainFileReader::Create(const std::string& filename) bool PlainFileReader::Read(u64 offset, u64 nbytes, u8* out_ptr) { - m_file.Seek(offset, SEEK_SET); - return m_file.ReadBytes(out_ptr, nbytes); + if (m_file.Seek(offset, SEEK_SET) && m_file.ReadBytes(out_ptr, nbytes)) + { + return true; + } + else + { + m_file.Clear(); + return false; + } } } // namespace diff --git a/Source/Core/DiscIO/WbfsBlob.cpp b/Source/Core/DiscIO/WbfsBlob.cpp index 77a5864490..08cb4ec078 100644 --- a/Source/Core/DiscIO/WbfsBlob.cpp +++ b/Source/Core/DiscIO/WbfsBlob.cpp @@ -130,7 +130,11 @@ bool WbfsFileReader::Read(u64 offset, u64 nbytes, u8* out_ptr) File::IOFile& data_file = SeekToCluster(offset, &read_size); read_size = (read_size > nbytes) ? nbytes : read_size; - data_file.ReadBytes(out_ptr, read_size); + if (!data_file.ReadBytes(out_ptr, read_size)) + { + data_file.Clear(); + return false; + } out_ptr += read_size; nbytes -= read_size;