mirror of
https://github.com/pocoproject/poco.git
synced 2025-07-05 10:00:01 +02:00
parent
2bd71b4ea4
commit
08fe7fd200
@ -22,7 +22,6 @@
|
|||||||
#include "Poco/Zip/ZipCommon.h"
|
#include "Poco/Zip/ZipCommon.h"
|
||||||
#include "Poco/Zip/ZipUtil.h"
|
#include "Poco/Zip/ZipUtil.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
namespace Zip {
|
namespace Zip {
|
||||||
|
|
||||||
|
@ -83,6 +83,12 @@ void Compress::addEntry(std::istream& in, const Poco::DateTime& lastModifiedAt,
|
|||||||
|
|
||||||
std::streamoff localHeaderOffset = _offset;
|
std::streamoff localHeaderOffset = _offset;
|
||||||
ZipLocalFileHeader hdr(fileName, lastModifiedAt, cm, cl, _forceZip64);
|
ZipLocalFileHeader hdr(fileName, lastModifiedAt, cm, cl, _forceZip64);
|
||||||
|
std::streampos pos = in.tellg();
|
||||||
|
in.seekg(0, in.end);
|
||||||
|
std::streampos length = in.tellg();
|
||||||
|
in.seekg(pos);
|
||||||
|
if (length >= ZipCommon::ZIP64_MAGIC)
|
||||||
|
hdr.setZip64Data();
|
||||||
hdr.setStartPos(localHeaderOffset);
|
hdr.setStartPos(localHeaderOffset);
|
||||||
|
|
||||||
ZipOutputStream zipOut(_out, hdr, _seekableOut);
|
ZipOutputStream zipOut(_out, hdr, _seekableOut);
|
||||||
@ -321,11 +327,11 @@ ZipArchive Compress::close()
|
|||||||
ZipArchive::FileInfos::const_iterator it = _infos.begin();
|
ZipArchive::FileInfos::const_iterator it = _infos.begin();
|
||||||
ZipArchive::FileInfos::const_iterator itEnd = _infos.end();
|
ZipArchive::FileInfos::const_iterator itEnd = _infos.end();
|
||||||
bool needZip64 = _forceZip64;
|
bool needZip64 = _forceZip64;
|
||||||
needZip64 = needZip64 || _files.size() >= ZipCommon::ZIP64_MAGIC_SHORT || centralDirStart64 >= ZipCommon::ZIP64_MAGIC;
|
needZip64 = needZip64 || _files.size() >= ZipCommon::ZIP64_MAGIC_SHORT || centralDirStart64 >= ZipCommon::ZIP64_MAGIC;
|
||||||
for (; it != itEnd; ++it)
|
for (; it != itEnd; ++it)
|
||||||
{
|
{
|
||||||
const ZipFileInfo& nfo = it->second;
|
const ZipFileInfo& nfo = it->second;
|
||||||
needZip64 = needZip64 || nfo.needsZip64();
|
needZip64 = needZip64 || nfo.needsZip64();
|
||||||
|
|
||||||
std::string info(nfo.createHeader());
|
std::string info(nfo.createHeader());
|
||||||
_out.write(info.c_str(), static_cast<std::streamsize>(info.size()));
|
_out.write(info.c_str(), static_cast<std::streamsize>(info.size()));
|
||||||
@ -336,7 +342,7 @@ ZipArchive Compress::close()
|
|||||||
if (!_out) throw Poco::IOException("Bad output stream");
|
if (!_out) throw Poco::IOException("Bad output stream");
|
||||||
|
|
||||||
Poco::UInt64 numEntries64 = _infos.size();
|
Poco::UInt64 numEntries64 = _infos.size();
|
||||||
needZip64 = needZip64 || _offset >= ZipCommon::ZIP64_MAGIC;
|
needZip64 = needZip64 || _offset >= ZipCommon::ZIP64_MAGIC;
|
||||||
if (needZip64)
|
if (needZip64)
|
||||||
{
|
{
|
||||||
ZipArchiveInfo64 central;
|
ZipArchiveInfo64 central;
|
||||||
|
@ -243,7 +243,8 @@ void ZipLocalFileHeader::init(const Poco::Path& fName, ZipCommon::CompressionMet
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
setCompressionMethod(ZipCommon::CM_STORE);
|
setCompressionMethod(ZipCommon::CM_STORE);
|
||||||
if (_forceZip64)
|
|
||||||
|
if (needsZip64())
|
||||||
setZip64Data();
|
setZip64Data();
|
||||||
|
|
||||||
_rawHeader[GENERAL_PURPOSE_POS+1] |= 0x08; // Set "language encoding flag" to indicate that filenames and paths are in UTF-8.
|
_rawHeader[GENERAL_PURPOSE_POS+1] |= 0x08; // Set "language encoding flag" to indicate that filenames and paths are in UTF-8.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user