Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/kornelski/7z.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Pavlov <ipavlov@users.sourceforge.net>2010-04-15 04:00:00 +0400
committerKornel LesiƄski <kornel@geekhood.net>2016-05-28 02:16:03 +0300
commit3dacb5eb8afda99aad81f4723cb966c0fa91ba1d (patch)
tree1e1f05aaadf64b4ff99d21bcd4282e8ab4365396 /CPP/7zip/Archive/Zip
parent76b173af78d09dea806d3ed35c0f67a09b496357 (diff)
9.139.13
Diffstat (limited to 'CPP/7zip/Archive/Zip')
-rwxr-xr-xCPP/7zip/Archive/Zip/ZipHandler.cpp10
-rwxr-xr-xCPP/7zip/Archive/Zip/ZipHandler.h2
-rwxr-xr-xCPP/7zip/Archive/Zip/ZipIn.cpp52
-rwxr-xr-xCPP/7zip/Archive/Zip/ZipIn.h6
-rwxr-xr-xCPP/7zip/Archive/Zip/ZipOut.cpp8
-rwxr-xr-xCPP/7zip/Archive/Zip/ZipOut.h2
-rwxr-xr-xCPP/7zip/Archive/Zip/ZipUpdate.cpp31
7 files changed, 56 insertions, 55 deletions
diff --git a/CPP/7zip/Archive/Zip/ZipHandler.cpp b/CPP/7zip/Archive/Zip/ZipHandler.cpp
index 64477766..e54b15ba 100755
--- a/CPP/7zip/Archive/Zip/ZipHandler.cpp
+++ b/CPP/7zip/Archive/Zip/ZipHandler.cpp
@@ -128,7 +128,9 @@ static STATPROPSTG kProps[] =
static STATPROPSTG kArcProps[] =
{
{ NULL, kpidBit64, VT_BOOL},
- { NULL, kpidComment, VT_BSTR}
+ { NULL, kpidComment, VT_BSTR},
+ { NULL, kpidPhySize, VT_UI8},
+ { NULL, kpidOffset, VT_UI8}
};
CHandler::CHandler()
@@ -160,9 +162,9 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
switch(propID)
{
case kpidBit64: if (m_Archive.IsZip64) prop = m_Archive.IsZip64; break;
- case kpidComment:
- prop = MultiByteToUnicodeString(BytesToString(m_Archive.m_ArchiveInfo.Comment), CP_ACP);
- break;
+ case kpidComment: prop = MultiByteToUnicodeString(BytesToString(m_Archive.ArcInfo.Comment), CP_ACP); break;
+ case kpidPhySize: prop = m_Archive.ArcInfo.GetPhySize(); break;
+ case kpidOffset: if (m_Archive.ArcInfo.StartPosition != 0) prop = m_Archive.ArcInfo.StartPosition; break;
}
prop.Detach(value);
COM_TRY_END
diff --git a/CPP/7zip/Archive/Zip/ZipHandler.h b/CPP/7zip/Archive/Zip/ZipHandler.h
index 55ebff25..68dd60dc 100755
--- a/CPP/7zip/Archive/Zip/ZipHandler.h
+++ b/CPP/7zip/Archive/Zip/ZipHandler.h
@@ -87,7 +87,7 @@ private:
m_ForceAesMode = false;
m_IsAesMode = false;
m_AesKeyMode = 3; // aes-256
- m_WriteNtfsTimeExtra = false;
+ m_WriteNtfsTimeExtra = true;
m_ForseLocal = false;
m_ForseUtf8 = false;
#ifndef _7ZIP_ST
diff --git a/CPP/7zip/Archive/Zip/ZipIn.cpp b/CPP/7zip/Archive/Zip/ZipIn.cpp
index a311e7f3..1048b57d 100755
--- a/CPP/7zip/Archive/Zip/ZipIn.cpp
+++ b/CPP/7zip/Archive/Zip/ZipIn.cpp
@@ -63,7 +63,7 @@ static inline bool TestMarkerCandidate2(const Byte *p, UInt32 &value)
HRESULT CInArchive::FindAndReadMarker(IInStream *stream, const UInt64 *searchHeaderSizeLimit)
{
- m_ArchiveInfo.Clear();
+ ArcInfo.Clear();
m_Position = m_StreamStartPosition;
Byte marker[NSignature::kMarkerSize];
@@ -99,7 +99,7 @@ HRESULT CInArchive::FindAndReadMarker(IInStream *stream, const UInt64 *searchHea
if (TestMarkerCandidate2(buffer + pos, m_Signature))
{
curTestPos += pos;
- m_ArchiveInfo.StartPosition = curTestPos;
+ ArcInfo.StartPosition = curTestPos;
m_Position = curTestPos + NSignature::kMarkerSize;
return S_OK;
}
@@ -208,11 +208,6 @@ void CInArchive::ReadFileName(UInt32 nameSize, AString &dest)
dest.ReleaseBuffer();
}
-void CInArchive::GetArchiveInfo(CInArchiveInfo &archiveInfo) const
-{
- archiveInfo = m_ArchiveInfo;
-}
-
void CInArchive::ReadExtra(UInt32 extraSize, CExtraBlock &extraBlock,
UInt64 &unpackSize, UInt64 &packSize, UInt64 &localHeaderOffset, UInt32 &diskStartNumber)
{
@@ -332,7 +327,7 @@ HRESULT CInArchive::ReadLocalItemAfterCdItem(CItemEx &item)
return S_OK;
try
{
- RINOK(Seek(m_ArchiveInfo.Base + item.LocalHeaderPosition));
+ RINOK(Seek(ArcInfo.Base + item.LocalHeaderPosition));
CItemEx localItem;
if (ReadUInt32() != NSignature::kLocalFileHeader)
return S_FALSE;
@@ -419,7 +414,7 @@ HRESULT CInArchive::ReadLocalItemAfterCdItemFull(CItemEx &item)
RINOK(ReadLocalItemAfterCdItem(item));
if (item.HasDescriptor())
{
- RINOK(Seek(m_ArchiveInfo.Base + item.GetDataPosition() + item.PackSize));
+ RINOK(Seek(ArcInfo.Base + item.GetDataPosition() + item.PackSize));
if (ReadUInt32() != NSignature::kDataDescriptor)
return S_FALSE;
UInt32 crc = ReadUInt32();
@@ -534,9 +529,9 @@ HRESULT CInArchive::FindCd(CCdInfo &cdInfo)
UInt64 ecd64Offset = Get64(locator + 8);
if (TryEcd64(ecd64Offset, cdInfo) == S_OK)
return S_OK;
- if (TryEcd64(m_ArchiveInfo.StartPosition + ecd64Offset, cdInfo) == S_OK)
+ if (TryEcd64(ArcInfo.StartPosition + ecd64Offset, cdInfo) == S_OK)
{
- m_ArchiveInfo.Base = m_ArchiveInfo.StartPosition;
+ ArcInfo.Base = ArcInfo.StartPosition;
return S_OK;
}
}
@@ -548,8 +543,8 @@ HRESULT CInArchive::FindCd(CCdInfo &cdInfo)
cdInfo.Offset = Get32(buf + i + 16);
UInt64 curPos = endPosition - bufSize + i;
UInt64 cdEnd = cdInfo.Size + cdInfo.Offset;
- if (curPos > cdEnd)
- m_ArchiveInfo.Base = curPos - cdEnd;
+ if (curPos != cdEnd)
+ ArcInfo.Base = curPos - cdEnd;
return S_OK;
}
}
@@ -585,18 +580,18 @@ HRESULT CInArchive::TryReadCd(CObjectVector<CItemEx> &items, UInt64 cdOffset, UI
HRESULT CInArchive::ReadCd(CObjectVector<CItemEx> &items, UInt64 &cdOffset, UInt64 &cdSize, CProgressVirt *progress)
{
- m_ArchiveInfo.Base = 0;
+ ArcInfo.Base = 0;
CCdInfo cdInfo;
RINOK(FindCd(cdInfo));
HRESULT res = S_FALSE;
cdSize = cdInfo.Size;
cdOffset = cdInfo.Offset;
- res = TryReadCd(items, m_ArchiveInfo.Base + cdOffset, cdSize, progress);
- if (res == S_FALSE && m_ArchiveInfo.Base == 0)
+ res = TryReadCd(items, ArcInfo.Base + cdOffset, cdSize, progress);
+ if (res == S_FALSE && ArcInfo.Base == 0)
{
- res = TryReadCd(items, cdInfo.Offset + m_ArchiveInfo.StartPosition, cdSize, progress);
+ res = TryReadCd(items, cdInfo.Offset + ArcInfo.StartPosition, cdSize, progress);
if (res == S_OK)
- m_ArchiveInfo.Base = m_ArchiveInfo.StartPosition;
+ ArcInfo.Base = ArcInfo.StartPosition;
}
if (!ReadUInt32(m_Signature))
return S_FALSE;
@@ -645,7 +640,7 @@ HRESULT CInArchive::ReadLocalsAndCd(CObjectVector<CItemEx> &items, CProgressVirt
CItemEx &item = items[j];
if (item.Name == cdItem.Name)
{
- m_ArchiveInfo.Base = item.LocalHeaderPosition - cdItem.LocalHeaderPosition;
+ ArcInfo.Base = item.LocalHeaderPosition - cdItem.LocalHeaderPosition;
break;
}
}
@@ -660,7 +655,7 @@ HRESULT CInArchive::ReadLocalsAndCd(CObjectVector<CItemEx> &items, CProgressVirt
if (left >= right)
return S_FALSE;
index = (left + right) / 2;
- UInt64 position = items[index].LocalHeaderPosition - m_ArchiveInfo.Base;
+ UInt64 position = items[index].LocalHeaderPosition - ArcInfo.Base;
if (cdItem.LocalHeaderPosition == position)
break;
if (cdItem.LocalHeaderPosition < position)
@@ -693,7 +688,7 @@ HRESULT CInArchive::ReadLocalsAndCd(CObjectVector<CItemEx> &items, CProgressVirt
return S_FALSE;
}
for (i = 0; i < items.Size(); i++)
- items[i].LocalHeaderPosition -= m_ArchiveInfo.Base;
+ items[i].LocalHeaderPosition -= ArcInfo.Base;
return S_OK;
}
@@ -781,20 +776,20 @@ HRESULT CInArchive::ReadHeaders(CObjectVector<CItemEx> &items, CProgressVirt *pr
if (res == S_FALSE)
{
_inBufMode = false;
- m_ArchiveInfo.Base = 0;
- RINOK(m_Stream->Seek(m_ArchiveInfo.StartPosition, STREAM_SEEK_SET, &m_Position));
- if (m_Position != m_ArchiveInfo.StartPosition)
+ ArcInfo.Base = 0;
+ RINOK(m_Stream->Seek(ArcInfo.StartPosition, STREAM_SEEK_SET, &m_Position));
+ if (m_Position != ArcInfo.StartPosition)
return S_FALSE;
if (!ReadUInt32(m_Signature))
return S_FALSE;
RINOK(ReadLocalsAndCd(items, progress, cdStartOffset, numCdItems));
cdSize = (m_Position - 4) - cdStartOffset;
- cdStartOffset -= m_ArchiveInfo.Base;
+ cdStartOffset -= ArcInfo.Base;
}
CEcd64 ecd64;
bool isZip64 = false;
- UInt64 zip64EcdStartOffset = m_Position - 4 - m_ArchiveInfo.Base;
+ UInt64 zip64EcdStartOffset = m_Position - 4 - ArcInfo.Base;
if (m_Signature == NSignature::kZip64EndOfCentralDir)
{
IsZip64 = isZip64 = true;
@@ -843,7 +838,7 @@ HRESULT CInArchive::ReadHeaders(CObjectVector<CItemEx> &items, CProgressVirt *pr
COPY_ECD_ITEM_32(cdSize);
COPY_ECD_ITEM_32(cdStartOffset);
- ReadBuffer(m_ArchiveInfo.Comment, ecd.commentSize);
+ ReadBuffer(ArcInfo.Comment, ecd.commentSize);
if (ecd64.thisDiskNumber != 0 || ecd64.startCDDiskNumber != 0)
throw CInArchiveException(CInArchiveException::kMultiVolumeArchiveAreNotSupported);
@@ -857,6 +852,7 @@ HRESULT CInArchive::ReadHeaders(CObjectVector<CItemEx> &items, CProgressVirt *pr
_inBufMode = false;
_inBuffer.Free();
IsOkHeaders = (numCdItems == items.Size());
+ ArcInfo.FinishPosition = m_Position;
return S_OK;
}
@@ -864,7 +860,7 @@ ISequentialInStream* CInArchive::CreateLimitedStream(UInt64 position, UInt64 siz
{
CLimitedSequentialInStream *streamSpec = new CLimitedSequentialInStream;
CMyComPtr<ISequentialInStream> stream(streamSpec);
- SeekInArchive(m_ArchiveInfo.Base + position);
+ SeekInArchive(ArcInfo.Base + position);
streamSpec->SetStream(m_Stream);
streamSpec->Init(size);
return stream.Detach();
diff --git a/CPP/7zip/Archive/Zip/ZipIn.h b/CPP/7zip/Archive/Zip/ZipIn.h
index f0e88b03..0565339a 100755
--- a/CPP/7zip/Archive/Zip/ZipIn.h
+++ b/CPP/7zip/Archive/Zip/ZipIn.h
@@ -38,8 +38,11 @@ class CInArchiveInfo
public:
UInt64 Base;
UInt64 StartPosition;
+ UInt64 FinishPosition;
CByteBuffer Comment;
+
CInArchiveInfo(): Base(0), StartPosition(0) {}
+ UInt64 GetPhySize() const { return FinishPosition - StartPosition; }
void Clear()
{
Base = 0;
@@ -101,7 +104,7 @@ class CInArchive
HRESULT ReadCd(CObjectVector<CItemEx> &items, UInt64 &cdOffset, UInt64 &cdSize, CProgressVirt *progress);
HRESULT ReadLocalsAndCd(CObjectVector<CItemEx> &items, CProgressVirt *progress, UInt64 &cdOffset, int &numCdItems);
public:
- CInArchiveInfo m_ArchiveInfo;
+ CInArchiveInfo ArcInfo;
bool IsZip64;
bool IsOkHeaders;
@@ -110,7 +113,6 @@ public:
HRESULT ReadLocalItemAfterCdItemFull(CItemEx &item);
HRESULT Open(IInStream *stream, const UInt64 *searchHeaderSizeLimit);
void Close();
- void GetArchiveInfo(CInArchiveInfo &archiveInfo) const;
bool SeekInArchive(UInt64 position);
ISequentialInStream *CreateLimitedStream(UInt64 position, UInt64 size);
IInStream* CreateStream();
diff --git a/CPP/7zip/Archive/Zip/ZipOut.cpp b/CPP/7zip/Archive/Zip/ZipOut.cpp
index 0807369c..aa82143e 100755
--- a/CPP/7zip/Archive/Zip/ZipOut.cpp
+++ b/CPP/7zip/Archive/Zip/ZipOut.cpp
@@ -221,7 +221,7 @@ void COutArchive::WriteCentralHeader(const CItem &item)
WriteBytes(item.Comment, (UInt32)item.Comment.GetCapacity());
}
-void COutArchive::WriteCentralDir(const CObjectVector<CItem> &items, const CByteBuffer &comment)
+void COutArchive::WriteCentralDir(const CObjectVector<CItem> &items, const CByteBuffer *comment)
{
SeekTo(m_BasePosition);
@@ -260,10 +260,10 @@ void COutArchive::WriteCentralDir(const CObjectVector<CItem> &items, const CByte
WriteUInt16((UInt16)(items64 ? 0xFFFF: items.Size()));
WriteUInt32(cdSize64 ? 0xFFFFFFFF: (UInt32)cdSize);
WriteUInt32(cdOffset64 ? 0xFFFFFFFF: (UInt32)cdOffset);
- UInt16 commentSize = (UInt16)comment.GetCapacity();
- WriteUInt16(commentSize);
+ UInt32 commentSize = (UInt32)(comment ? comment->GetCapacity() : 0);
+ WriteUInt16((UInt16)commentSize);
if (commentSize > 0)
- WriteBytes((const Byte *)comment, commentSize);
+ WriteBytes((const Byte *)*comment, commentSize);
m_OutBuffer.FlushWithCheck();
}
diff --git a/CPP/7zip/Archive/Zip/ZipOut.h b/CPP/7zip/Archive/Zip/ZipOut.h
index 24bc83a1..2f6349e5 100755
--- a/CPP/7zip/Archive/Zip/ZipOut.h
+++ b/CPP/7zip/Archive/Zip/ZipOut.h
@@ -44,7 +44,7 @@ public:
void PrepareWriteCompressedData2(UInt16 fileNameLength, UInt64 unPackSize, UInt64 packSize, bool aesEncryption);
void WriteLocalHeader(const CLocalItem &item);
- void WriteCentralDir(const CObjectVector<CItem> &items, const CByteBuffer &comment);
+ void WriteCentralDir(const CObjectVector<CItem> &items, const CByteBuffer *comment);
void CreateStreamForCompressing(IOutStream **outStream);
void CreateStreamForCopying(ISequentialOutStream **outStream);
diff --git a/CPP/7zip/Archive/Zip/ZipUpdate.cpp b/CPP/7zip/Archive/Zip/ZipUpdate.cpp
index 004e67f8..6dd20f94 100755
--- a/CPP/7zip/Archive/Zip/ZipUpdate.cpp
+++ b/CPP/7zip/Archive/Zip/ZipUpdate.cpp
@@ -398,7 +398,7 @@ static HRESULT Update2St(
const CObjectVector<CItemEx> &inputItems,
const CObjectVector<CUpdateItem> &updateItems,
const CCompressionMethodMode *options,
- const CByteBuffer &comment,
+ const CByteBuffer *comment,
IArchiveUpdateCallback *updateCallback)
{
CLocalProgress *lps = new CLocalProgress;
@@ -482,7 +482,7 @@ static HRESULT Update2(
const CObjectVector<CItemEx> &inputItems,
const CObjectVector<CUpdateItem> &updateItems,
const CCompressionMethodMode *options,
- const CByteBuffer &comment,
+ const CByteBuffer *comment,
IArchiveUpdateCallback *updateCallback)
{
UInt64 complexity = 0;
@@ -515,8 +515,8 @@ static HRESULT Update2(
complexity += NFileHeader::kCentralBlockSize;
}
- if (comment != 0)
- complexity += comment.GetCapacity();
+ if (comment)
+ complexity += comment->GetCapacity();
complexity++; // end of central
updateCallback->SetTotal(complexity);
@@ -812,27 +812,27 @@ HRESULT Update(
if (!outStream)
return E_NOTIMPL;
- CInArchiveInfo archiveInfo;
- if(inArchive != 0)
+ if (inArchive)
{
- inArchive->GetArchiveInfo(archiveInfo);
- if (archiveInfo.Base != 0 || !inArchive->IsOkHeaders)
+ if (inArchive->ArcInfo.Base != 0 ||
+ inArchive->ArcInfo.StartPosition != 0 ||
+ !inArchive->IsOkHeaders)
return E_NOTIMPL;
}
- else
- archiveInfo.StartPosition = 0;
COutArchive outArchive;
outArchive.Create(outStream);
- if (archiveInfo.StartPosition > 0)
+ /*
+ if (inArchive && inArchive->ArcInfo.StartPosition > 0)
{
CMyComPtr<ISequentialInStream> inStream;
- inStream.Attach(inArchive->CreateLimitedStream(0, archiveInfo.StartPosition));
+ inStream.Attach(inArchive->CreateLimitedStream(0, inArchive->ArcInfo.StartPosition));
RINOK(CopyBlockToArchive(inStream, outArchive, NULL));
- outArchive.MoveBasePosition(archiveInfo.StartPosition);
+ outArchive.MoveBasePosition(inArchive->ArcInfo.StartPosition);
}
+ */
CMyComPtr<IInStream> inStream;
- if(inArchive != 0)
+ if (inArchive)
inStream.Attach(inArchive->CreateStream());
return Update2(
@@ -840,7 +840,8 @@ HRESULT Update(
outArchive, inArchive, inStream,
inputItems, updateItems,
compressionMethodMode,
- archiveInfo.Comment, updateCallback);
+ inArchive ? &inArchive->ArcInfo.Comment : NULL,
+ updateCallback);
}
}}