Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DiscIO: Clear error status when reading file #1700

Merged
merged 1 commit into from
Dec 16, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions Source/Core/DiscIO/CISOBlob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
11 changes: 9 additions & 2 deletions Source/Core/DiscIO/FileBlob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 5 additions & 1 deletion Source/Core/DiscIO/WbfsBlob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down