9.06 beta

This commit is contained in:
Igor Pavlov
2009-08-17 00:00:00 +00:00
committed by Kornel Lesiński
parent 829409452d
commit c99f3ebdd6
445 changed files with 15246 additions and 8133 deletions

View File

@@ -448,7 +448,7 @@ HRESULT CZipDecoder::Decode(
ICompressProgressInfo *compressProgress,
UInt32 numThreads, Int32 &res)
{
res = NArchive::NExtract::NOperationResult::kDataError;
res = NExtract::NOperationResult::kDataError;
CInStreamReleaser inStreamReleaser;
bool needCRC = true;
@@ -466,7 +466,7 @@ HRESULT CZipDecoder::Decode(
}
if (!pkAesMode)
{
res = NArchive::NExtract::NOperationResult::kUnSupportedMethod;
res = NExtract::NOperationResult::kUnSupportedMethod;
return S_OK;
}
}
@@ -560,7 +560,7 @@ HRESULT CZipDecoder::Decode(
break;
if (c >= 0x80)
{
res = NArchive::NExtract::NOperationResult::kDataError;
res = NExtract::NOperationResult::kDataError;
return S_OK;
}
charPassword += (char)c;
@@ -609,7 +609,7 @@ HRESULT CZipDecoder::Decode(
{
if (methodId > 0xFF)
{
res = NArchive::NExtract::NOperationResult::kUnSupportedMethod;
res = NExtract::NOperationResult::kUnSupportedMethod;
return S_OK;
}
szMethodID = kMethodId_ZipBase + (Byte)methodId;
@@ -619,7 +619,7 @@ HRESULT CZipDecoder::Decode(
if (mi.Coder == 0)
{
res = NArchive::NExtract::NOperationResult::kUnSupportedMethod;
res = NExtract::NOperationResult::kUnSupportedMethod;
return S_OK;
}
}
@@ -699,7 +699,7 @@ HRESULT CZipDecoder::Decode(
return S_OK;
if (result == E_NOTIMPL)
{
res = NArchive::NExtract::NOperationResult::kUnSupportedMethod;
res = NExtract::NOperationResult::kUnSupportedMethod;
return S_OK;
}
@@ -717,26 +717,25 @@ HRESULT CZipDecoder::Decode(
}
res = ((crcOK && authOk) ?
NArchive::NExtract::NOperationResult::kOK :
NArchive::NExtract::NOperationResult::kCRCError);
NExtract::NOperationResult::kOK :
NExtract::NOperationResult::kCRCError);
return S_OK;
}
STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
Int32 _aTestMode, IArchiveExtractCallback *extractCallback)
STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
Int32 testMode, IArchiveExtractCallback *extractCallback)
{
COM_TRY_BEGIN
CZipDecoder myDecoder;
bool testMode = (_aTestMode != 0);
UInt64 totalUnPacked = 0, totalPacked = 0;
bool allFilesMode = (numItems == UInt32(-1));
bool allFilesMode = (numItems == (UInt32)-1);
if (allFilesMode)
numItems = m_Items.Size();
if(numItems == 0)
return S_OK;
UInt32 i;
for(i = 0; i < numItems; i++)
for (i = 0; i < numItems; i++)
{
const CItemEx &item = m_Items[allFilesMode ? i : indices[i]];
totalUnPacked += item.UnPackSize;
@@ -763,8 +762,8 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
CMyComPtr<ISequentialOutStream> realOutStream;
Int32 askMode = testMode ?
NArchive::NExtract::NAskMode::kTest :
NArchive::NExtract::NAskMode::kExtract;
NExtract::NAskMode::kTest :
NExtract::NAskMode::kExtract;
Int32 index = allFilesMode ? i : indices[i];
RINOK(extractCallback->GetStream(index, &realOutStream, askMode));
@@ -779,7 +778,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
{
RINOK(extractCallback->PrepareOperation(askMode));
realOutStream.Release();
RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kUnSupportedMethod));
RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kUnSupportedMethod));
}
continue;
}
@@ -792,7 +791,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
{
RINOK(extractCallback->PrepareOperation(askMode));
realOutStream.Release();
RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK));
RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kOK));
}
continue;
}
@@ -800,7 +799,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
currentItemUnPacked = item.UnPackSize;
currentItemPacked = item.PackSize;
if (!testMode && (!realOutStream))
if (!testMode && !realOutStream)
continue;
RINOK(extractCallback->PrepareOperation(askMode));

View File

@@ -112,7 +112,7 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
ui.NewData = IntToBool(newData);
ui.IndexInArchive = indexInArchive;
ui.IndexInClient = i;
bool existInArchive = (indexInArchive != UInt32(-1));
bool existInArchive = (indexInArchive != (UInt32)-1);
if (existInArchive && newData)
if (m_Items[indexInArchive].IsAesEncrypted())
thereAreAesUpdates = true;

View File

@@ -318,14 +318,17 @@ HRESULT CInArchive::ReadLocalItemAfterCdItem(CItemEx &item)
RINOK(ReadLocalItem(localItem));
if (item.Flags != localItem.Flags)
{
if (
(item.CompressionMethod != NFileHeader::NCompressionMethod::kDeflated ||
(item.Flags & 0x7FF9) != (localItem.Flags & 0x7FF9)) &&
(item.CompressionMethod != NFileHeader::NCompressionMethod::kStored ||
(item.Flags & 0x7FFF) != (localItem.Flags & 0x7FFF)) &&
(item.CompressionMethod != NFileHeader::NCompressionMethod::kImploded ||
(item.Flags & 0x7FFF) != (localItem.Flags & 0x7FFF))
)
UInt32 mask = 0xFFFF;
switch(item.CompressionMethod)
{
case NFileHeader::NCompressionMethod::kDeflated:
mask = 0x7FF9;
break;
default:
if (item.CompressionMethod <= NFileHeader::NCompressionMethod::kImploded)
mask = 0x7FFF;
}
if ((item.Flags & mask) != (localItem.Flags & mask))
return S_FALSE;
}
@@ -501,7 +504,9 @@ HRESULT CInArchive::FindCd(CCdInfo &cdInfo)
UInt64 endPosition;
RINOK(m_Stream->Seek(0, STREAM_SEEK_END, &endPosition));
const UInt32 kBufSizeMax = (1 << 16) + kEcdSize + kZip64EcdLocatorSize;
Byte buf[kBufSizeMax];
CByteBuffer byteBuffer;
byteBuffer.SetCapacity(kBufSizeMax);
Byte *buf = byteBuffer;
UInt32 bufSize = (endPosition < kBufSizeMax) ? (UInt32)endPosition : kBufSizeMax;
if (bufSize < kEcdSize)
return S_FALSE;
@@ -622,10 +627,7 @@ HRESULT CInArchive::ReadLocalsAndCd(CObjectVector<CItemEx> &items, CProgressVirt
RINOK(ReadCdItem(cdItem));
if (i == 0)
{
if (cdItem.LocalHeaderPosition == 0)
m_ArchiveInfo.Base = m_ArchiveInfo.StartPosition;
}
m_ArchiveInfo.Base = items[i].LocalHeaderPosition - cdItem.LocalHeaderPosition;
int index;
int left = 0, right = items.Size();
@@ -733,7 +735,15 @@ HRESULT CInArchive::ReadHeaders(CObjectVector<CItemEx> &items, CProgressVirt *pr
items.Clear();
UInt64 cdSize, cdStartOffset;
HRESULT res = ReadCd(items, cdStartOffset, cdSize, progress);
HRESULT res;
try
{
res = ReadCd(items, cdStartOffset, cdSize, progress);
}
catch(CInArchiveException &)
{
res = S_FALSE;
}
if (res != S_FALSE && res != S_OK)
return res;
@@ -793,7 +803,7 @@ HRESULT CInArchive::ReadHeaders(CObjectVector<CItemEx> &items, CProgressVirt *pr
return S_FALSE;
}
if (m_Signature != NSignature::kEndOfCentralDir)
return S_FALSE;
return S_FALSE;
const int kBufSize = kEcdSize - 4;
Byte buf[kBufSize];
@@ -817,7 +827,7 @@ HRESULT CInArchive::ReadHeaders(CObjectVector<CItemEx> &items, CProgressVirt *pr
(UInt32)ecd64.cdSize != (UInt32)cdSize ||
((UInt32)(ecd64.cdStartOffset) != (UInt32)cdStartOffset &&
(!items.IsEmpty())))
return S_FALSE;
return S_FALSE;
_inBufMode = false;
_inBuffer.Free();

View File

@@ -5,14 +5,14 @@
#include "../../Common/RegisterArc.h"
#include "ZipHandler.h"
static IInArchive *CreateArc() { return new NArchive::NZip::CHandler; }
static IInArchive *CreateArc() { return new NArchive::NZip::CHandler; }
#ifndef EXTRACT_ONLY
static IOutArchive *CreateArcOut() { return new NArchive::NZip::CHandler; }
static IOutArchive *CreateArcOut() { return new NArchive::NZip::CHandler; }
#else
#define CreateArcOut 0
#endif
static CArcInfo g_ArcInfo =
{ L"Zip", L"zip jar xpi odt ods docx xlsx", 0, 1, { 0x50, 0x4B, 0x03, 0x04 }, 4, false, CreateArc, CreateArcOut };
{ L"zip", L"zip jar xpi odt ods docx xlsx", 0, 1, { 0x50, 0x4B, 0x03, 0x04 }, 4, false, CreateArc, CreateArcOut };
REGISTER_ARC(Zip)