mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-20 22:31:31 +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:
@@ -190,6 +190,8 @@ private:
|
|||||||
Poco::UInt32 _crc32;
|
Poco::UInt32 _crc32;
|
||||||
Poco::UInt32 _compressedSize;
|
Poco::UInt32 _compressedSize;
|
||||||
Poco::UInt32 _uncompressedSize;
|
Poco::UInt32 _uncompressedSize;
|
||||||
|
|
||||||
|
friend class ZipStreamBuf;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@@ -219,6 +219,13 @@ void ZipStreamBuf::close()
|
|||||||
_pHeader->setCRC(_crc32.checksum());
|
_pHeader->setCRC(_crc32.checksum());
|
||||||
_pHeader->setUncompressedSize(_bytesWritten);
|
_pHeader->setUncompressedSize(_bytesWritten);
|
||||||
_pHeader->setCompressedSize(_ptrOHelper->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
|
_pHeader->setStartPos(_pHeader->getStartPos()); // This resets EndPos now that compressed Size is known
|
||||||
|
|
||||||
if (_pHeader->searchCRCAndSizesAfterData())
|
if (_pHeader->searchCRCAndSizesAfterData())
|
||||||
|
Reference in New Issue
Block a user