summaryrefslogtreecommitdiff
path: root/Source/Core/DiscIO/FileBlob.cpp
diff options
context:
space:
mode:
authorJosJuice <josjuice@gmail.com>2020-04-10 17:40:07 +0200
committerJosJuice <josjuice@gmail.com>2020-04-24 15:11:20 +0200
commit6ffcbcee70c043a0d158d87458f99d20eddbb939 (patch)
tree9782c56a64cb48afa5e2f3af437032712e060efc /Source/Core/DiscIO/FileBlob.cpp
parent04c7892b93f4ae129609060be5347628fa29eced (diff)
DiscIO: Move scrubbing code out of ConvertToGCZ
This way, scrubbing can also be performed when converting to other formats.
Diffstat (limited to 'Source/Core/DiscIO/FileBlob.cpp')
-rw-r--r--Source/Core/DiscIO/FileBlob.cpp21
1 files changed, 7 insertions, 14 deletions
diff --git a/Source/Core/DiscIO/FileBlob.cpp b/Source/Core/DiscIO/FileBlob.cpp
index 95beeb1bc3..ca0aa2cfd0 100644
--- a/Source/Core/DiscIO/FileBlob.cpp
+++ b/Source/Core/DiscIO/FileBlob.cpp
@@ -41,17 +41,10 @@ bool PlainFileReader::Read(u64 offset, u64 nbytes, u8* out_ptr)
}
}
-bool ConvertToPlain(const std::string& infile_path, const std::string& outfile_path,
- CompressCB callback, void* arg)
+bool ConvertToPlain(BlobReader* infile, const std::string& infile_path,
+ const std::string& outfile_path, CompressCB callback, void* arg)
{
- std::unique_ptr<BlobReader> reader = CreateBlobReader(infile_path);
- if (!reader)
- {
- PanicAlertT("Failed to open the input file \"%s\".", infile_path.c_str());
- return false;
- }
-
- ASSERT(reader->IsDataSizeAccurate());
+ ASSERT(infile->IsDataSizeAccurate());
File::IOFile outfile(outfile_path, "wb");
if (!outfile)
@@ -64,7 +57,7 @@ bool ConvertToPlain(const std::string& infile_path, const std::string& outfile_p
}
constexpr size_t DESIRED_BUFFER_SIZE = 0x80000;
- u64 buffer_size = reader->GetBlockSize();
+ u64 buffer_size = infile->GetBlockSize();
if (buffer_size == 0)
{
buffer_size = DESIRED_BUFFER_SIZE;
@@ -76,7 +69,7 @@ bool ConvertToPlain(const std::string& infile_path, const std::string& outfile_p
}
std::vector<u8> buffer(buffer_size);
- const u64 num_buffers = (reader->GetDataSize() + buffer_size - 1) / buffer_size;
+ const u64 num_buffers = (infile->GetDataSize() + buffer_size - 1) / buffer_size;
int progress_monitor = std::max<int>(1, num_buffers / 100);
bool success = true;
@@ -93,8 +86,8 @@ bool ConvertToPlain(const std::string& infile_path, const std::string& outfile_p
}
}
const u64 inpos = i * buffer_size;
- const u64 sz = std::min(buffer_size, reader->GetDataSize() - inpos);
- if (!reader->Read(inpos, sz, buffer.data()))
+ const u64 sz = std::min(buffer_size, infile->GetDataSize() - inpos);
+ if (!infile->Read(inpos, sz, buffer.data()))
{
PanicAlertT("Failed to read from the input file \"%s\".", infile_path.c_str());
success = false;