From 6ffcbcee70c043a0d158d87458f99d20eddbb939 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Fri, 10 Apr 2020 17:40:07 +0200 Subject: DiscIO: Move scrubbing code out of ConvertToGCZ This way, scrubbing can also be performed when converting to other formats. --- Source/Core/DiscIO/CompressedBlob.cpp | 37 +++++++---------------------------- 1 file changed, 7 insertions(+), 30 deletions(-) (limited to 'Source/Core/DiscIO/CompressedBlob.cpp') diff --git a/Source/Core/DiscIO/CompressedBlob.cpp b/Source/Core/DiscIO/CompressedBlob.cpp index 5e6723679a..cda3cad6d3 100644 --- a/Source/Core/DiscIO/CompressedBlob.cpp +++ b/Source/Core/DiscIO/CompressedBlob.cpp @@ -154,19 +154,11 @@ bool CompressedBlobReader::GetBlock(u64 block_num, u8* out_ptr) return true; } -bool ConvertToGCZ(const std::string& infile_path, const std::string& outfile_path, u32 sub_type, - int block_size, CompressCB callback, void* arg) +bool ConvertToGCZ(BlobReader* infile, const std::string& infile_path, + const std::string& outfile_path, u32 sub_type, int block_size, + CompressCB callback, void* arg) { - bool scrubbing = false; - - std::unique_ptr infile = CreateDisc(infile_path); - if (!infile) - { - PanicAlertT("Failed to open the input file \"%s\".", infile_path.c_str()); - return false; - } - - ASSERT(infile->IsSizeAccurate()); + ASSERT(infile->IsDataSizeAccurate()); File::IOFile outfile(outfile_path, "wb"); if (!outfile) @@ -178,19 +170,6 @@ bool ConvertToGCZ(const std::string& infile_path, const std::string& outfile_pat return false; } - DiscScrubber disc_scrubber; - if (sub_type == 1) - { - if (!disc_scrubber.SetupScrub(infile.get())) - { - PanicAlertT("\"%s\" failed to be scrubbed. Probably the image is corrupt.", - infile_path.c_str()); - return false; - } - - scrubbing = true; - } - z_stream z = {}; if (deflateInit(&z, 9) != Z_OK) return false; @@ -201,7 +180,7 @@ bool ConvertToGCZ(const std::string& infile_path, const std::string& outfile_pat header.magic_cookie = GCZ_MAGIC; header.sub_type = sub_type; header.block_size = block_size; - header.data_size = infile->GetSize(); + header.data_size = infile->GetDataSize(); // round upwards! header.num_blocks = (u32)((header.data_size + (block_size - 1)) / block_size); @@ -245,11 +224,9 @@ bool ConvertToGCZ(const std::string& infile_path, const std::string& outfile_pat offsets[i] = position; - const u64 bytes_to_read = scrubbing && disc_scrubber.CanBlockBeScrubbed(inpos) ? - 0 : - std::min(block_size, header.data_size - inpos); + const u64 bytes_to_read = std::min(block_size, header.data_size - inpos); - success = infile->Read(inpos, bytes_to_read, in_buf.data(), PARTITION_NONE); + success = infile->Read(inpos, bytes_to_read, in_buf.data()); if (!success) { PanicAlertT("Failed to read from the input file \"%s\".", infile_path.c_str()); -- cgit v1.2.3