summaryrefslogtreecommitdiff
path: root/Source/Core/DiscIO/CompressedBlob.cpp
diff options
context:
space:
mode:
authorJosJuice <josjuice@gmail.com>2020-04-04 21:47:28 +0200
committerJosJuice <josjuice@gmail.com>2020-04-24 15:10:35 +0200
commit42f6913bccdafcb8a32e5d82bd54947062cfd0a9 (patch)
tree30c7a33229543c8452c9c34f2304b64b9cb5c4f3 /Source/Core/DiscIO/CompressedBlob.cpp
parent8a9597e32e98707d5bcdc1a41d8c45e3174d4047 (diff)
Move DiscIO::ConvertToPlain to FileBlob.cpp
There is no longer anything GCZ specific about it.
Diffstat (limited to 'Source/Core/DiscIO/CompressedBlob.cpp')
-rw-r--r--Source/Core/DiscIO/CompressedBlob.cpp79
1 files changed, 0 insertions, 79 deletions
diff --git a/Source/Core/DiscIO/CompressedBlob.cpp b/Source/Core/DiscIO/CompressedBlob.cpp
index 33790ad3b0..5e6723679a 100644
--- a/Source/Core/DiscIO/CompressedBlob.cpp
+++ b/Source/Core/DiscIO/CompressedBlob.cpp
@@ -336,85 +336,6 @@ bool ConvertToGCZ(const std::string& infile_path, const std::string& outfile_pat
return success;
}
-bool ConvertToPlain(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());
-
- File::IOFile outfile(outfile_path, "wb");
- if (!outfile)
- {
- PanicAlertT("Failed to open the output file \"%s\".\n"
- "Check that you have permissions to write the target folder and that the media can "
- "be written.",
- outfile_path.c_str());
- return false;
- }
-
- constexpr size_t DESIRED_BUFFER_SIZE = 0x80000;
- u64 buffer_size = reader->GetBlockSize();
- if (buffer_size == 0)
- {
- buffer_size = DESIRED_BUFFER_SIZE;
- }
- else
- {
- while (buffer_size < DESIRED_BUFFER_SIZE)
- buffer_size *= 2;
- }
-
- std::vector<u8> buffer(buffer_size);
- const u64 num_buffers = (reader->GetDataSize() + buffer_size - 1) / buffer_size;
- int progress_monitor = std::max<int>(1, num_buffers / 100);
- bool success = true;
-
- for (u64 i = 0; i < num_buffers; i++)
- {
- if (i % progress_monitor == 0)
- {
- const bool was_cancelled =
- !callback(Common::GetStringT("Unpacking"), (float)i / (float)num_buffers, arg);
- if (was_cancelled)
- {
- success = false;
- break;
- }
- }
- const u64 inpos = i * buffer_size;
- const u64 sz = std::min(buffer_size, reader->GetDataSize() - inpos);
- if (!reader->Read(inpos, sz, buffer.data()))
- {
- PanicAlertT("Failed to read from the input file \"%s\".", infile_path.c_str());
- success = false;
- break;
- }
- if (!outfile.WriteBytes(buffer.data(), sz))
- {
- PanicAlertT("Failed to write the output file \"%s\".\n"
- "Check that you have enough space available on the target drive.",
- outfile_path.c_str());
- success = false;
- break;
- }
- }
-
- if (!success)
- {
- // Remove the incomplete output file.
- outfile.Close();
- File::Delete(outfile_path);
- }
-
- return success;
-}
-
bool IsGCZBlob(File::IOFile& file)
{
const u64 position = file.Tell();