DiscIO: On decompress to file, write last blocks.
This commit is contained in:
parent
f2f2d61950
commit
df5857b5af
|
@ -316,8 +316,9 @@ bool DecompressBlobToFile(const std::string& infile, const std::string& outfile,
|
|||
const CompressedBlobHeader &header = reader->GetHeader();
|
||||
static const size_t BUFFER_BLOCKS = 32;
|
||||
size_t buffer_size = header.block_size * BUFFER_BLOCKS;
|
||||
size_t last_buffer_size = header.block_size * (header.num_blocks % BUFFER_BLOCKS);
|
||||
std::vector<u8> buffer(buffer_size);
|
||||
u32 num_buffers = header.num_blocks / BUFFER_BLOCKS;
|
||||
u32 num_buffers = (header.num_blocks + BUFFER_BLOCKS - 1) / BUFFER_BLOCKS;
|
||||
int progress_monitor = std::max<int>(1, num_buffers / 100);
|
||||
bool was_cancelled = false;
|
||||
|
||||
|
@ -329,8 +330,9 @@ bool DecompressBlobToFile(const std::string& infile, const std::string& outfile,
|
|||
if (was_cancelled)
|
||||
break;
|
||||
}
|
||||
reader->Read(i * buffer_size, buffer_size, buffer.data());
|
||||
f.WriteBytes(buffer.data(), buffer_size);
|
||||
const size_t sz = i == num_buffers - 1 ? last_buffer_size : buffer_size;
|
||||
reader->Read(i * buffer_size, sz, buffer.data());
|
||||
f.WriteBytes(buffer.data(), sz);
|
||||
}
|
||||
|
||||
if (was_cancelled)
|
||||
|
|
Loading…
Reference in New Issue