diff options
| author | JosJuice <josjuice@gmail.com> | 2017-06-17 13:28:14 +0200 |
|---|---|---|
| committer | JosJuice <josjuice@gmail.com> | 2017-06-28 22:21:55 +0200 |
| commit | 1f31390b54f17f7dd5bd8f17f1842d76b9a4697d (patch) | |
| tree | b89ca145a6bb71cb4c14bb4ef4a8e5380a55123f /Source/Core/DiscIO/DiscExtractor.cpp | |
| parent | a17272c1467a5e655c309a619e839c00e1538acd (diff) | |
DiscExtractor: Improve error handling
Diffstat (limited to 'Source/Core/DiscIO/DiscExtractor.cpp')
| -rw-r--r-- | Source/Core/DiscIO/DiscExtractor.cpp | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/Source/Core/DiscIO/DiscExtractor.cpp b/Source/Core/DiscIO/DiscExtractor.cpp index e8ef494f4d..430ab7f55f 100644 --- a/Source/Core/DiscIO/DiscExtractor.cpp +++ b/Source/Core/DiscIO/DiscExtractor.cpp @@ -28,7 +28,8 @@ u64 ReadFile(const Volume& volume, const Partition& partition, const FileInfo* f read_length, offset_in_file, file_info->GetPath().c_str(), file_info->GetOffset(), file_info->GetSize()); - volume.Read(file_info->GetOffset() + offset_in_file, read_length, buffer, partition); + if (!volume.Read(file_info->GetOffset() + offset_in_file, read_length, buffer, partition)) + return 0; return read_length; } @@ -56,7 +57,8 @@ bool ExportFile(const Volume& volume, const Partition& partition, const FileInfo if (!volume.Read(file_offset, read_size, buffer.data(), partition)) return false; - f.WriteBytes(buffer.data(), read_size); + if (!f.WriteBytes(buffer.data(), read_size)) + return false; remaining_size -= read_size; file_offset += read_size; @@ -85,11 +87,8 @@ bool ExportApploader(const Volume& volume, const Partition& partition, const std::string export_name(export_folder + "/apploader.img"); File::IOFile apploader_file(export_name, "wb"); - if (apploader_file) - { - apploader_file.WriteBytes(buffer.data(), *apploader_size); + if (apploader_file.WriteBytes(buffer.data(), *apploader_size)) return true; - } } return false; @@ -154,11 +153,8 @@ bool ExportDOL(const Volume& volume, const Partition& partition, const std::stri const std::string export_name(export_folder + "/boot.dol"); File::IOFile dol_file(export_name, "wb"); - if (dol_file) - { - dol_file.WriteBytes(buffer.data(), *dol_size); + if (dol_file.WriteBytes(buffer.data(), *dol_size)) return true; - } } return false; |
