mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-14 06:11:36 -06:00
23.01
This commit is contained in:
@@ -18,7 +18,7 @@ bool CCabBlockInStream::Create()
|
||||
{
|
||||
if (!_buf)
|
||||
_buf = (Byte *)::MyAlloc(kBlockSize);
|
||||
return _buf != 0;
|
||||
return _buf != NULL;
|
||||
}
|
||||
|
||||
CCabBlockInStream::~CCabBlockInStream()
|
||||
@@ -60,7 +60,7 @@ HRESULT CCabBlockInStream::PreRead(ISequentialInStream *stream, UInt32 &packSize
|
||||
unpackSize = GetUi16(header + 6);
|
||||
if (packSize > kBlockSize - _size)
|
||||
return S_FALSE;
|
||||
RINOK(ReadStream_FALSE(stream, _buf + _size, packSize));
|
||||
RINOK(ReadStream_FALSE(stream, _buf + _size, packSize))
|
||||
|
||||
if (MsZip)
|
||||
{
|
||||
@@ -82,7 +82,7 @@ HRESULT CCabBlockInStream::PreRead(ISequentialInStream *stream, UInt32 &packSize
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CCabBlockInStream::Read(void *data, UInt32 size, UInt32 *processedSize)
|
||||
Z7_COM7F_IMF(CCabBlockInStream::Read(void *data, UInt32 size, UInt32 *processedSize))
|
||||
{
|
||||
if (size != 0)
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// CabBlockInStream.h
|
||||
|
||||
#ifndef __CAB_BLOCK_IN_STREAM_H
|
||||
#define __CAB_BLOCK_IN_STREAM_H
|
||||
#ifndef ZIP7_INC_CAB_BLOCK_IN_STREAM_H
|
||||
#define ZIP7_INC_CAB_BLOCK_IN_STREAM_H
|
||||
|
||||
#include "../../../Common/MyCom.h"
|
||||
#include "../../IStream.h"
|
||||
@@ -9,10 +9,10 @@
|
||||
namespace NArchive {
|
||||
namespace NCab {
|
||||
|
||||
class CCabBlockInStream:
|
||||
public ISequentialInStream,
|
||||
public CMyUnknownImp
|
||||
{
|
||||
Z7_CLASS_IMP_NOQIB_1(
|
||||
CCabBlockInStream
|
||||
, ISequentialInStream
|
||||
)
|
||||
Byte *_buf;
|
||||
UInt32 _size;
|
||||
UInt32 _pos;
|
||||
@@ -21,9 +21,7 @@ public:
|
||||
UInt32 ReservedSize; // < 256
|
||||
bool MsZip;
|
||||
|
||||
MY_UNKNOWN_IMP
|
||||
|
||||
CCabBlockInStream(): _buf(0), ReservedSize(0), MsZip(false) {}
|
||||
CCabBlockInStream(): _buf(NULL), ReservedSize(0), MsZip(false) {}
|
||||
~CCabBlockInStream();
|
||||
|
||||
bool Create();
|
||||
@@ -34,8 +32,6 @@ public:
|
||||
|
||||
UInt32 GetPackSizeAvail() const { return _size - _pos; }
|
||||
const Byte *GetData() const { return _buf + _pos; }
|
||||
|
||||
STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
@@ -32,9 +32,9 @@ using namespace NWindows;
|
||||
namespace NArchive {
|
||||
namespace NCab {
|
||||
|
||||
// #define _CAB_DETAILS
|
||||
// #define CAB_DETAILS
|
||||
|
||||
#ifdef _CAB_DETAILS
|
||||
#ifdef CAB_DETAILS
|
||||
enum
|
||||
{
|
||||
kpidBlockReal = kpidUserDefined
|
||||
@@ -49,7 +49,7 @@ static const Byte kProps[] =
|
||||
kpidAttrib,
|
||||
kpidMethod,
|
||||
kpidBlock
|
||||
#ifdef _CAB_DETAILS
|
||||
#ifdef CAB_DETAILS
|
||||
,
|
||||
// kpidBlockReal, // L"BlockReal",
|
||||
kpidOffset,
|
||||
@@ -83,7 +83,7 @@ static const unsigned kMethodNameBufSize = 32; // "Quantum:255"
|
||||
|
||||
static void SetMethodName(char *s, unsigned method, unsigned param)
|
||||
{
|
||||
if (method < ARRAY_SIZE(kMethods))
|
||||
if (method < Z7_ARRAY_SIZE(kMethods))
|
||||
{
|
||||
s = MyStpCpy(s, kMethods[method]);
|
||||
if (method != NHeader::NMethod::kLZX &&
|
||||
@@ -95,7 +95,7 @@ static void SetMethodName(char *s, unsigned method, unsigned param)
|
||||
ConvertUInt32ToString(method, s);
|
||||
}
|
||||
|
||||
STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
|
||||
Z7_COM7F_IMF(CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value))
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
NCOM::CPropVariant prop;
|
||||
@@ -267,7 +267,7 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
|
||||
Z7_COM7F_IMF(CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value))
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
NCOM::CPropVariant prop;
|
||||
@@ -305,7 +305,7 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
|
||||
if (realFolderIndex >= 0)
|
||||
{
|
||||
const CFolder &folder = db.Folders[(unsigned)realFolderIndex];
|
||||
char s[kMethodNameBufSize];;
|
||||
char s[kMethodNameBufSize];
|
||||
SetMethodName(s, folder.GetMethod(), folder.MethodMinor);
|
||||
prop = s;
|
||||
}
|
||||
@@ -314,7 +314,7 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
|
||||
|
||||
case kpidBlock: prop.Set_Int32((Int32)m_Database.GetFolderIndex(&mvItem)); break;
|
||||
|
||||
#ifdef _CAB_DETAILS
|
||||
#ifdef CAB_DETAILS
|
||||
|
||||
// case kpidBlockReal: prop = (UInt32)item.FolderIndex; break;
|
||||
case kpidOffset: prop = (UInt32)item.Offset; break;
|
||||
@@ -327,9 +327,9 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
STDMETHODIMP CHandler::Open(IInStream *inStream,
|
||||
Z7_COM7F_IMF(CHandler::Open(IInStream *inStream,
|
||||
const UInt64 *maxCheckStartPosition,
|
||||
IArchiveOpenCallback *callback)
|
||||
IArchiveOpenCallback *callback))
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
Close();
|
||||
@@ -418,7 +418,7 @@ STDMETHODIMP CHandler::Open(IInStream *inStream,
|
||||
|
||||
if (callback)
|
||||
{
|
||||
RINOK(callback->SetCompleted(&numItems, NULL));
|
||||
RINOK(callback->SetCompleted(&numItems, NULL))
|
||||
}
|
||||
|
||||
nextStream = NULL;
|
||||
@@ -471,7 +471,7 @@ STDMETHODIMP CHandler::Open(IInStream *inStream,
|
||||
startVolName_was_Requested = true;
|
||||
{
|
||||
NCOM::CPropVariant prop;
|
||||
RINOK(openVolumeCallback->GetProperty(kpidName, &prop));
|
||||
RINOK(openVolumeCallback->GetProperty(kpidName, &prop))
|
||||
if (prop.vt == VT_BSTR)
|
||||
startVolName = prop.bstrVal;
|
||||
}
|
||||
@@ -520,7 +520,7 @@ STDMETHODIMP CHandler::Open(IInStream *inStream,
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CHandler::Close()
|
||||
Z7_COM7F_IMF(CHandler::Close())
|
||||
{
|
||||
_errorMessage.Empty();
|
||||
_isArc = false;
|
||||
@@ -534,15 +534,11 @@ STDMETHODIMP CHandler::Close()
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
class CFolderOutStream:
|
||||
public ISequentialOutStream,
|
||||
public CMyUnknownImp
|
||||
{
|
||||
public:
|
||||
MY_UNKNOWN_IMP
|
||||
|
||||
STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
|
||||
private:
|
||||
Z7_CLASS_IMP_NOQIB_1(
|
||||
CFolderOutStream
|
||||
, ISequentialOutStream
|
||||
)
|
||||
const CMvDatabaseEx *m_Database;
|
||||
const CRecordVector<bool> *m_ExtractStatuses;
|
||||
|
||||
@@ -681,10 +677,10 @@ HRESULT CFolderOutStream::OpenFile()
|
||||
while (NumIdenticalFiles && !(*m_ExtractStatuses)[m_CurrentIndex])
|
||||
{
|
||||
CMyComPtr<ISequentialOutStream> stream;
|
||||
RINOK(m_ExtractCallback->GetStream(m_StartIndex + m_CurrentIndex, &stream, NExtract::NAskMode::kSkip));
|
||||
RINOK(m_ExtractCallback->GetStream(m_StartIndex + m_CurrentIndex, &stream, NExtract::NAskMode::kSkip))
|
||||
if (stream)
|
||||
return E_FAIL;
|
||||
RINOK(m_ExtractCallback->PrepareOperation(NExtract::NAskMode::kSkip));
|
||||
RINOK(m_ExtractCallback->PrepareOperation(NExtract::NAskMode::kSkip))
|
||||
m_CurrentIndex++;
|
||||
m_FileIsOpen = true;
|
||||
CloseFile();
|
||||
@@ -692,11 +688,11 @@ HRESULT CFolderOutStream::OpenFile()
|
||||
}
|
||||
}
|
||||
|
||||
Int32 askMode = (*m_ExtractStatuses)[m_CurrentIndex] ? (m_TestMode ?
|
||||
Int32 askMode = (*m_ExtractStatuses)[m_CurrentIndex] ? m_TestMode ?
|
||||
NExtract::NAskMode::kTest :
|
||||
NExtract::NAskMode::kExtract) :
|
||||
NExtract::NAskMode::kExtract :
|
||||
NExtract::NAskMode::kSkip;
|
||||
RINOK(m_ExtractCallback->GetStream(m_StartIndex + m_CurrentIndex, &m_RealOutStream, askMode));
|
||||
RINOK(m_ExtractCallback->GetStream(m_StartIndex + m_CurrentIndex, &m_RealOutStream, askMode))
|
||||
if (!m_RealOutStream && !m_TestMode)
|
||||
askMode = NExtract::NAskMode::kSkip;
|
||||
return m_ExtractCallback->PrepareOperation(askMode);
|
||||
@@ -716,14 +712,14 @@ HRESULT CFolderOutStream::WriteEmptyFiles()
|
||||
return S_OK;
|
||||
HRESULT result = OpenFile();
|
||||
m_RealOutStream.Release();
|
||||
RINOK(result);
|
||||
RINOK(m_ExtractCallback->SetOperationResult(NExtract::NOperationResult::kOK));
|
||||
RINOK(result)
|
||||
RINOK(m_ExtractCallback->SetOperationResult(NExtract::NOperationResult::kOK))
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
HRESULT CFolderOutStream::Write(const void *data, UInt32 size, UInt32 *processedSize)
|
||||
Z7_COM7F_IMF(CFolderOutStream::Write(const void *data, UInt32 size, UInt32 *processedSize))
|
||||
{
|
||||
// (data == NULL) means Error_Data for solid folder flushing
|
||||
COM_TRY_BEGIN
|
||||
@@ -777,7 +773,7 @@ HRESULT CFolderOutStream::Write(const void *data, UInt32 size, UInt32 *processed
|
||||
|
||||
if (m_RemainFileSize == 0)
|
||||
{
|
||||
RINOK(CloseFile());
|
||||
RINOK(CloseFile())
|
||||
|
||||
while (NumIdenticalFiles)
|
||||
{
|
||||
@@ -789,14 +785,14 @@ HRESULT CFolderOutStream::Write(const void *data, UInt32 size, UInt32 *processed
|
||||
|
||||
if (!TempBuf && TempBufMode && m_RealOutStream)
|
||||
{
|
||||
RINOK(CloseFileWithResOp(NExtract::NOperationResult::kUnsupportedMethod));
|
||||
RINOK(CloseFileWithResOp(NExtract::NOperationResult::kUnsupportedMethod))
|
||||
}
|
||||
else
|
||||
{
|
||||
RINOK(CloseFile());
|
||||
RINOK(CloseFile())
|
||||
}
|
||||
|
||||
RINOK(result);
|
||||
RINOK(result)
|
||||
}
|
||||
|
||||
TempBufMode = false;
|
||||
@@ -842,7 +838,7 @@ HRESULT CFolderOutStream::Write(const void *data, UInt32 size, UInt32 *processed
|
||||
|
||||
if (fileOffset == m_PosInFolder)
|
||||
{
|
||||
RINOK(OpenFile());
|
||||
RINOK(OpenFile())
|
||||
m_FileIsOpen = true;
|
||||
m_CurrentIndex++;
|
||||
m_IsOk = true;
|
||||
@@ -860,11 +856,11 @@ HRESULT CFolderOutStream::FlushCorrupted(unsigned folderIndex)
|
||||
{
|
||||
if (!NeedMoreWrite())
|
||||
{
|
||||
CMyComPtr<IArchiveExtractCallbackMessage> callbackMessage;
|
||||
m_ExtractCallback.QueryInterface(IID_IArchiveExtractCallbackMessage, &callbackMessage);
|
||||
CMyComPtr<IArchiveExtractCallbackMessage2> callbackMessage;
|
||||
m_ExtractCallback.QueryInterface(IID_IArchiveExtractCallbackMessage2, &callbackMessage);
|
||||
if (callbackMessage)
|
||||
{
|
||||
RINOK(callbackMessage->ReportExtractResult(NEventIndexType::kBlockIndex, folderIndex, NExtract::NOperationResult::kDataError));
|
||||
RINOK(callbackMessage->ReportExtractResult(NEventIndexType::kBlockIndex, folderIndex, NExtract::NOperationResult::kDataError))
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
@@ -878,7 +874,7 @@ HRESULT CFolderOutStream::FlushCorrupted(unsigned folderIndex)
|
||||
if (size > remain)
|
||||
size = (UInt32)remain;
|
||||
UInt32 processedSizeLocal = 0;
|
||||
RINOK(Write(NULL, size, &processedSizeLocal));
|
||||
RINOK(Write(NULL, size, &processedSizeLocal))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -891,19 +887,18 @@ HRESULT CFolderOutStream::Unsupported()
|
||||
if (result != S_FALSE && result != S_OK)
|
||||
return result;
|
||||
m_RealOutStream.Release();
|
||||
RINOK(m_ExtractCallback->SetOperationResult(NExtract::NOperationResult::kUnsupportedMethod));
|
||||
RINOK(m_ExtractCallback->SetOperationResult(NExtract::NOperationResult::kUnsupportedMethod))
|
||||
m_CurrentIndex++;
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
Int32 testModeSpec, IArchiveExtractCallback *extractCallback)
|
||||
Z7_COM7F_IMF(CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
Int32 testModeSpec, IArchiveExtractCallback *extractCallback))
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
|
||||
bool allFilesMode = (numItems == (UInt32)(Int32)-1);
|
||||
const bool allFilesMode = (numItems == (UInt32)(Int32)-1);
|
||||
if (allFilesMode)
|
||||
numItems = m_Database.Items.Size();
|
||||
if (numItems == 0)
|
||||
@@ -964,45 +959,45 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
{
|
||||
lps->OutSize = totalUnPacked;
|
||||
lps->InSize = totalPacked;
|
||||
RINOK(lps->SetCur());
|
||||
RINOK(lps->SetCur())
|
||||
|
||||
if (i >= numItems)
|
||||
break;
|
||||
|
||||
unsigned index = allFilesMode ? i : indices[i];
|
||||
const unsigned index = allFilesMode ? i : indices[i];
|
||||
|
||||
const CMvItem &mvItem = m_Database.Items[index];
|
||||
const CDatabaseEx &db = m_Database.Volumes[mvItem.VolumeIndex];
|
||||
unsigned itemIndex = mvItem.ItemIndex;
|
||||
const unsigned itemIndex = mvItem.ItemIndex;
|
||||
const CItem &item = db.Items[itemIndex];
|
||||
|
||||
i++;
|
||||
if (item.IsDir())
|
||||
{
|
||||
Int32 askMode = testMode ?
|
||||
const Int32 askMode = testMode ?
|
||||
NExtract::NAskMode::kTest :
|
||||
NExtract::NAskMode::kExtract;
|
||||
CMyComPtr<ISequentialOutStream> realOutStream;
|
||||
RINOK(extractCallback->GetStream(index, &realOutStream, askMode));
|
||||
RINOK(extractCallback->PrepareOperation(askMode));
|
||||
RINOK(extractCallback->GetStream(index, &realOutStream, askMode))
|
||||
RINOK(extractCallback->PrepareOperation(askMode))
|
||||
realOutStream.Release();
|
||||
RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kOK));
|
||||
RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kOK))
|
||||
continue;
|
||||
}
|
||||
|
||||
int folderIndex = m_Database.GetFolderIndex(&mvItem);
|
||||
const int folderIndex = m_Database.GetFolderIndex(&mvItem);
|
||||
|
||||
if (folderIndex < 0)
|
||||
{
|
||||
// If we need previous archive
|
||||
Int32 askMode= testMode ?
|
||||
const Int32 askMode= testMode ?
|
||||
NExtract::NAskMode::kTest :
|
||||
NExtract::NAskMode::kExtract;
|
||||
CMyComPtr<ISequentialOutStream> realOutStream;
|
||||
RINOK(extractCallback->GetStream(index, &realOutStream, askMode));
|
||||
RINOK(extractCallback->PrepareOperation(askMode));
|
||||
RINOK(extractCallback->GetStream(index, &realOutStream, askMode))
|
||||
RINOK(extractCallback->PrepareOperation(askMode))
|
||||
realOutStream.Release();
|
||||
RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kDataError));
|
||||
RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kDataError))
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1017,12 +1012,12 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
|
||||
for (; i < numItems; i++)
|
||||
{
|
||||
unsigned indexNext = allFilesMode ? i : indices[i];
|
||||
const unsigned indexNext = allFilesMode ? i : indices[i];
|
||||
const CMvItem &mvItem2 = m_Database.Items[indexNext];
|
||||
const CItem &item2 = m_Database.Volumes[mvItem2.VolumeIndex].Items[mvItem2.ItemIndex];
|
||||
if (item2.IsDir())
|
||||
continue;
|
||||
int newFolderIndex = m_Database.GetFolderIndex(&mvItem2);
|
||||
const int newFolderIndex = m_Database.GetFolderIndex(&mvItem2);
|
||||
|
||||
if (newFolderIndex != folderIndex)
|
||||
break;
|
||||
@@ -1086,11 +1081,11 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
|
||||
if (res == E_INVALIDARG)
|
||||
{
|
||||
RINOK(cabFolderOutStream->Unsupported());
|
||||
RINOK(cabFolderOutStream->Unsupported())
|
||||
totalUnPacked += curUnpack;
|
||||
continue;
|
||||
}
|
||||
RINOK(res);
|
||||
RINOK(res)
|
||||
|
||||
{
|
||||
unsigned volIndex = mvItem.VolumeIndex;
|
||||
@@ -1115,7 +1110,7 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
if (bl == 0)
|
||||
{
|
||||
cabBlockInStreamSpec->ReservedSize = db2.ArcInfo.GetDataBlockReserveSize();
|
||||
RINOK(db2.Stream->Seek((Int64)(db2.StartPosition + folder2.DataStart), STREAM_SEEK_SET, NULL));
|
||||
RINOK(InStream_SeekSet(db2.Stream, db2.StartPosition + folder2.DataStart))
|
||||
}
|
||||
|
||||
if (bl == folder2.NumDataBlocks)
|
||||
@@ -1146,7 +1141,7 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
res = cabBlockInStreamSpec->PreRead(db2.Stream, packSize, unpackSize);
|
||||
if (res == S_FALSE)
|
||||
break;
|
||||
RINOK(res);
|
||||
RINOK(res)
|
||||
keepInputBuffer = (unpackSize == 0);
|
||||
if (keepInputBuffer)
|
||||
continue;
|
||||
@@ -1156,7 +1151,7 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
|
||||
lps->OutSize = totalUnPacked2;
|
||||
lps->InSize = totalPacked;
|
||||
RINOK(lps->SetCur());
|
||||
RINOK(lps->SetCur())
|
||||
|
||||
const UInt32 kBlockSizeMax = (1 << 15);
|
||||
|
||||
@@ -1230,7 +1225,7 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
if (res != S_OK)
|
||||
{
|
||||
if (res != S_FALSE)
|
||||
RINOK(res);
|
||||
RINOK(res)
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1239,13 +1234,13 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
|
||||
if (res == S_OK)
|
||||
{
|
||||
RINOK(cabFolderOutStream->WriteEmptyFiles());
|
||||
RINOK(cabFolderOutStream->WriteEmptyFiles())
|
||||
}
|
||||
}
|
||||
|
||||
if (res != S_OK || cabFolderOutStream->NeedMoreWrite())
|
||||
{
|
||||
RINOK(cabFolderOutStream->FlushCorrupted((unsigned)folderIndex2));
|
||||
RINOK(cabFolderOutStream->FlushCorrupted((unsigned)folderIndex2))
|
||||
}
|
||||
|
||||
totalUnPacked += curUnpack;
|
||||
@@ -1257,7 +1252,7 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
}
|
||||
|
||||
|
||||
STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
|
||||
Z7_COM7F_IMF(CHandler::GetNumberOfItems(UInt32 *numItems))
|
||||
{
|
||||
*numItems = m_Database.Items.Size();
|
||||
return S_OK;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// CabHandler.h
|
||||
|
||||
#ifndef __CAB_HANDLER_H
|
||||
#define __CAB_HANDLER_H
|
||||
#ifndef ZIP7_INC_CAB_HANDLER_H
|
||||
#define ZIP7_INC_CAB_HANDLER_H
|
||||
|
||||
#include "../../../Common/MyCom.h"
|
||||
|
||||
@@ -12,16 +12,8 @@
|
||||
namespace NArchive {
|
||||
namespace NCab {
|
||||
|
||||
class CHandler:
|
||||
public IInArchive,
|
||||
public CMyUnknownImp
|
||||
{
|
||||
public:
|
||||
MY_UNKNOWN_IMP1(IInArchive)
|
||||
Z7_CLASS_IMP_CHandler_IInArchive_0
|
||||
|
||||
INTERFACE_IInArchive(;)
|
||||
|
||||
private:
|
||||
CMvDatabaseEx m_Database;
|
||||
UString _errorMessage;
|
||||
bool _isArc;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Archive/CabHeader.h
|
||||
|
||||
#ifndef __ARCHIVE_CAB_HEADER_H
|
||||
#define __ARCHIVE_CAB_HEADER_H
|
||||
#ifndef ZIP7_INC_ARCHIVE_CAB_HEADER_H
|
||||
#define ZIP7_INC_ARCHIVE_CAB_HEADER_H
|
||||
|
||||
#include "../../../Common/MyTypes.h"
|
||||
|
||||
|
||||
@@ -76,9 +76,9 @@ struct CSignatureFinder
|
||||
const Byte *Signature;
|
||||
UInt32 SignatureSize;
|
||||
|
||||
UInt32 _HeaderSize;
|
||||
UInt32 _AlignSize;
|
||||
UInt32 _BufUseCapacity;
|
||||
UInt32 _headerSize;
|
||||
UInt32 _alignSize;
|
||||
UInt32 _bufUseCapacity;
|
||||
|
||||
ISequentialInStream *Stream;
|
||||
UInt64 Processed; // Global offset of start of Buf
|
||||
@@ -87,10 +87,10 @@ struct CSignatureFinder
|
||||
|
||||
UInt32 GetTotalCapacity(UInt32 basicSize, UInt32 headerSize)
|
||||
{
|
||||
_HeaderSize = headerSize;
|
||||
for (_AlignSize = (1 << 5); _AlignSize < _HeaderSize; _AlignSize <<= 1);
|
||||
_BufUseCapacity = basicSize + _AlignSize;
|
||||
return _BufUseCapacity + 16;
|
||||
_headerSize = headerSize;
|
||||
for (_alignSize = (1 << 5); _alignSize < _headerSize; _alignSize <<= 1);
|
||||
_bufUseCapacity = basicSize + _alignSize;
|
||||
return _bufUseCapacity + 16;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -108,7 +108,7 @@ HRESULT CSignatureFinder::Find()
|
||||
{
|
||||
Buf[End] = Signature[0]; // it's for fast search;
|
||||
|
||||
while (End - Pos >= _HeaderSize)
|
||||
while (End - Pos >= _headerSize)
|
||||
{
|
||||
const Byte *p = Buf + Pos;
|
||||
Byte b = Signature[0];
|
||||
@@ -118,9 +118,9 @@ HRESULT CSignatureFinder::Find()
|
||||
if (*p == b) { break; } p++;
|
||||
}
|
||||
Pos = (UInt32)(p - Buf);
|
||||
if (End - Pos < _HeaderSize)
|
||||
if (End - Pos < _headerSize)
|
||||
{
|
||||
Pos = End - _HeaderSize + 1;
|
||||
Pos = End - _headerSize + 1;
|
||||
break;
|
||||
}
|
||||
UInt32 i;
|
||||
@@ -130,28 +130,28 @@ HRESULT CSignatureFinder::Find()
|
||||
Pos++;
|
||||
}
|
||||
|
||||
if (Pos >= _AlignSize)
|
||||
if (Pos >= _alignSize)
|
||||
{
|
||||
UInt32 num = (Pos & ~(_AlignSize - 1));
|
||||
UInt32 num = (Pos & ~(_alignSize - 1));
|
||||
Processed += num;
|
||||
Pos -= num;
|
||||
End -= num;
|
||||
memmove(Buf, Buf + num, End);
|
||||
}
|
||||
UInt32 rem = _BufUseCapacity - End;
|
||||
UInt32 rem = _bufUseCapacity - End;
|
||||
if (SearchLimit)
|
||||
{
|
||||
if (Processed + Pos > *SearchLimit)
|
||||
return S_FALSE;
|
||||
UInt64 rem2 = *SearchLimit - (Processed + End) + _HeaderSize;
|
||||
UInt64 rem2 = *SearchLimit - (Processed + End) + _headerSize;
|
||||
if (rem > rem2)
|
||||
rem = (UInt32)rem2;
|
||||
}
|
||||
|
||||
UInt32 processedSize;
|
||||
if (Processed == 0 && rem == _BufUseCapacity - _HeaderSize)
|
||||
rem -= _AlignSize; // to make reads more aligned.
|
||||
RINOK(Stream->Read(Buf + End, rem, &processedSize));
|
||||
if (Processed == 0 && rem == _bufUseCapacity - _headerSize)
|
||||
rem -= _alignSize; // to make reads more aligned.
|
||||
RINOK(Stream->Read(Buf + End, rem, &processedSize))
|
||||
if (processedSize == 0)
|
||||
return S_FALSE;
|
||||
End += processedSize;
|
||||
@@ -189,7 +189,7 @@ HRESULT CInArchive::Open2(CDatabaseEx &db, const UInt64 *searchHeaderSizeLimit)
|
||||
HeaderError = false;
|
||||
|
||||
db.Clear();
|
||||
RINOK(db.Stream->Seek(0, STREAM_SEEK_CUR, &db.StartPosition));
|
||||
RINOK(InStream_GetPos(db.Stream, db.StartPosition))
|
||||
// UInt64 temp = db.StartPosition;
|
||||
|
||||
CByteBuffer buffer;
|
||||
@@ -201,12 +201,12 @@ HRESULT CInArchive::Open2(CDatabaseEx &db, const UInt64 *searchHeaderSizeLimit)
|
||||
|
||||
// for (int iii = 0; iii < 10000; iii++)
|
||||
{
|
||||
// db.StartPosition = temp; RINOK(db.Stream->Seek(db.StartPosition, STREAM_SEEK_SET, NULL));
|
||||
// db.StartPosition = temp; RINOK(InStream_SeekSet(db.Stream, db.StartPosition))
|
||||
|
||||
const UInt32 kMainHeaderSize = 32;
|
||||
Byte header[kMainHeaderSize];
|
||||
const UInt32 kBufSize = 1 << 15;
|
||||
RINOK(ReadStream_FALSE(db.Stream, header, kMainHeaderSize));
|
||||
RINOK(ReadStream_FALSE(db.Stream, header, kMainHeaderSize))
|
||||
if (memcmp(header, NHeader::kMarker, NHeader::kMarkerSize) == 0 && ai.Parse(header))
|
||||
{
|
||||
limitedStreamSpec = new CLimitedSequentialInStream;
|
||||
@@ -216,7 +216,7 @@ HRESULT CInArchive::Open2(CDatabaseEx &db, const UInt64 *searchHeaderSizeLimit)
|
||||
buffer.Alloc(kBufSize);
|
||||
memcpy(buffer, header, kMainHeaderSize);
|
||||
UInt32 numProcessedBytes;
|
||||
RINOK(limitedStream->Read(buffer + kMainHeaderSize, kBufSize - kMainHeaderSize, &numProcessedBytes));
|
||||
RINOK(limitedStream->Read(buffer + kMainHeaderSize, kBufSize - kMainHeaderSize, &numProcessedBytes))
|
||||
_inBuffer.SetBuf(buffer, (UInt32)kBufSize, kMainHeaderSize + numProcessedBytes, kMainHeaderSize);
|
||||
}
|
||||
else
|
||||
@@ -241,7 +241,7 @@ HRESULT CInArchive::Open2(CDatabaseEx &db, const UInt64 *searchHeaderSizeLimit)
|
||||
|
||||
for (;;)
|
||||
{
|
||||
RINOK(finder.Find());
|
||||
RINOK(finder.Find())
|
||||
if (ai.Parse(finder.Buf + finder.Pos))
|
||||
{
|
||||
db.StartPosition = finder.Processed + finder.Pos;
|
||||
@@ -311,7 +311,7 @@ HRESULT CInArchive::Open2(CDatabaseEx &db, const UInt64 *searchHeaderSizeLimit)
|
||||
{
|
||||
// printf("\n!!! Seek Error !!!!\n");
|
||||
// fflush(stdout);
|
||||
RINOK(db.Stream->Seek((Int64)(db.StartPosition + ai.FileHeadersOffset), STREAM_SEEK_SET, NULL));
|
||||
RINOK(InStream_SeekSet(db.Stream, db.StartPosition + ai.FileHeadersOffset))
|
||||
limitedStreamSpec->Init(ai.Size - ai.FileHeadersOffset);
|
||||
_inBuffer.Init();
|
||||
}
|
||||
@@ -357,7 +357,7 @@ HRESULT CInArchive::Open(CDatabaseEx &db, const UInt64 *searchHeaderSizeLimit)
|
||||
|
||||
|
||||
|
||||
#define RINOZ(x) { int __tt = (x); if (__tt != 0) return __tt; }
|
||||
#define RINOZ(x) { int _tt_ = (x); if (_tt_ != 0) return _tt_; }
|
||||
|
||||
static int CompareMvItems(const CMvItem *p1, const CMvItem *p2, void *param)
|
||||
{
|
||||
@@ -365,17 +365,17 @@ static int CompareMvItems(const CMvItem *p1, const CMvItem *p2, void *param)
|
||||
const CDatabaseEx &db1 = mvDb.Volumes[p1->VolumeIndex];
|
||||
const CDatabaseEx &db2 = mvDb.Volumes[p2->VolumeIndex];
|
||||
const CItem &item1 = db1.Items[p1->ItemIndex];
|
||||
const CItem &item2 = db2.Items[p2->ItemIndex];;
|
||||
const CItem &item2 = db2.Items[p2->ItemIndex];
|
||||
bool isDir1 = item1.IsDir();
|
||||
bool isDir2 = item2.IsDir();
|
||||
if (isDir1 && !isDir2) return -1;
|
||||
if (isDir2 && !isDir1) return 1;
|
||||
int f1 = mvDb.GetFolderIndex(p1);
|
||||
int f2 = mvDb.GetFolderIndex(p2);
|
||||
RINOZ(MyCompare(f1, f2));
|
||||
RINOZ(MyCompare(item1.Offset, item2.Offset));
|
||||
RINOZ(MyCompare(item1.Size, item2.Size));
|
||||
RINOZ(MyCompare(p1->VolumeIndex, p2->VolumeIndex));
|
||||
RINOZ(MyCompare(f1, f2))
|
||||
RINOZ(MyCompare(item1.Offset, item2.Offset))
|
||||
RINOZ(MyCompare(item1.Size, item2.Size))
|
||||
RINOZ(MyCompare(p1->VolumeIndex, p2->VolumeIndex))
|
||||
return MyCompare(p1->ItemIndex, p2->ItemIndex);
|
||||
}
|
||||
|
||||
@@ -387,7 +387,7 @@ bool CMvDatabaseEx::AreItemsEqual(unsigned i1, unsigned i2)
|
||||
const CDatabaseEx &db1 = Volumes[p1->VolumeIndex];
|
||||
const CDatabaseEx &db2 = Volumes[p2->VolumeIndex];
|
||||
const CItem &item1 = db1.Items[p1->ItemIndex];
|
||||
const CItem &item2 = db2.Items[p2->ItemIndex];;
|
||||
const CItem &item2 = db2.Items[p2->ItemIndex];
|
||||
return GetFolderIndex(p1) == GetFolderIndex(p2)
|
||||
&& item1.Offset == item2.Offset
|
||||
&& item1.Size == item2.Size
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Archive/CabIn.h
|
||||
|
||||
#ifndef __ARCHIVE_CAB_IN_H
|
||||
#define __ARCHIVE_CAB_IN_H
|
||||
#ifndef ZIP7_INC_ARCHIVE_CAB_IN_H
|
||||
#define ZIP7_INC_ARCHIVE_CAB_IN_H
|
||||
|
||||
#include "../../../Common/MyBuffer.h"
|
||||
#include "../../../Common/MyCom.h"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Archive/CabItem.h
|
||||
|
||||
#ifndef __ARCHIVE_CAB_ITEM_H
|
||||
#define __ARCHIVE_CAB_ITEM_H
|
||||
#ifndef ZIP7_INC_ARCHIVE_CAB_ITEM_H
|
||||
#define ZIP7_INC_ARCHIVE_CAB_ITEM_H
|
||||
|
||||
#include "../../../Common/MyString.h"
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace NArchive {
|
||||
namespace NCab {
|
||||
|
||||
REGISTER_ARC_I(
|
||||
"Cab", "cab", 0, 8,
|
||||
"Cab", "cab", NULL, 8,
|
||||
NHeader::kMarker,
|
||||
0,
|
||||
NArcInfoFlags::kFindSignature,
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
// StdAfx.h
|
||||
|
||||
#ifndef __STDAFX_H
|
||||
#define __STDAFX_H
|
||||
#ifndef ZIP7_INC_STDAFX_H
|
||||
#define ZIP7_INC_STDAFX_H
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1800
|
||||
#pragma warning(disable : 4464) // relative include path contains '..'
|
||||
#endif
|
||||
#include "../../../Common/Common.h"
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user