mirror of
https://github.com/pocoproject/poco.git
synced 2025-04-01 09:24:55 +02:00
fixed GH #1597: adding empty file to zip leads to archive that can't be unzipped by windows
This commit is contained in:
parent
7c81a551c4
commit
4ddce11dc0
@ -190,6 +190,8 @@ private:
|
||||
Poco::UInt32 _crc32;
|
||||
Poco::UInt32 _compressedSize;
|
||||
Poco::UInt32 _uncompressedSize;
|
||||
|
||||
friend class ZipStreamBuf;
|
||||
};
|
||||
|
||||
|
||||
|
@ -219,6 +219,13 @@ void ZipStreamBuf::close()
|
||||
_pHeader->setCRC(_crc32.checksum());
|
||||
_pHeader->setUncompressedSize(_bytesWritten);
|
||||
_pHeader->setCompressedSize(_ptrOHelper->bytesWritten());
|
||||
if (_bytesWritten == 0)
|
||||
{
|
||||
poco_assert (_ptrOHelper->bytesWritten() == 0);
|
||||
// Empty files must use CM_STORE, otherwise unzipping will fail
|
||||
_pHeader->setCompressionMethod(ZipCommon::CM_STORE);
|
||||
_pHeader->setCompressionLevel(ZipCommon::CL_NORMAL);
|
||||
}
|
||||
_pHeader->setStartPos(_pHeader->getStartPos()); // This resets EndPos now that compressed Size is known
|
||||
|
||||
if (_pHeader->searchCRCAndSizesAfterData())
|
||||
|
Loading…
x
Reference in New Issue
Block a user