DiscIO: On decompress to file, write last blocks.

This commit is contained in:
Unknown W. Brackets 2015-02-12 20:30:11 -08:00
parent f2f2d61950
commit df5857b5af
1 changed files with 5 additions and 3 deletions

View File

@ -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)