Fixed uncompressed size not being written correctly when store only. #352

This commit is contained in:
Nathan Moinvaziri 2018-12-01 07:56:28 -08:00
parent 6675c44613
commit d931843012
2 changed files with 12 additions and 9 deletions

View File

@ -469,7 +469,10 @@ int32_t mz_stream_raw_read(void *stream, void *buf, int32_t size)
read = mz_stream_read(raw->stream.base, buf, bytes_to_read);
if (read > 0)
{
raw->total_in += read;
raw->total_out += read;
}
return read;
}
@ -477,9 +480,16 @@ int32_t mz_stream_raw_read(void *stream, void *buf, int32_t size)
int32_t mz_stream_raw_write(void *stream, const void *buf, int32_t size)
{
mz_stream_raw *raw = (mz_stream_raw *)stream;
int32_t written = mz_stream_write(raw->stream.base, buf, size);
int32_t written = 0;
written = mz_stream_write(raw->stream.base, buf, size);
if (written > 0)
{
raw->total_out += written;
raw->total_in += written;
}
return written;
}
@ -498,7 +508,6 @@ int32_t mz_stream_raw_seek(void *stream, int64_t offset, int32_t origin)
int32_t mz_stream_raw_close(void *stream)
{
MZ_UNUSED(stream);
return MZ_OK;
}

View File

@ -2029,13 +2029,7 @@ int32_t mz_zip_entry_write_close(void *handle, uint32_t crc32, int64_t compresse
if (compressed_size < 0)
mz_stream_get_prop_int64(zip->compress_stream, MZ_STREAM_PROP_TOTAL_OUT, &compressed_size);
if (uncompressed_size < 0)
{
/* If using raw stream as compression stream in/out are equal */
if (zip->entry_raw)
uncompressed_size = compressed_size;
else
mz_stream_get_prop_int64(zip->compress_stream, MZ_STREAM_PROP_TOTAL_IN, &uncompressed_size);
}
mz_stream_get_prop_int64(zip->compress_stream, MZ_STREAM_PROP_TOTAL_IN, &uncompressed_size);
if (zip->file_info.flag & MZ_ZIP_FLAG_ENCRYPTED)
{