mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-13 16:11:34 -06:00
23.01
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
|
||||
#ifdef USE_MIXER_ST
|
||||
|
||||
STDMETHODIMP CSequentialInStreamCalcSize::Read(void *data, UInt32 size, UInt32 *processedSize)
|
||||
Z7_COM7F_IMF(CSequentialInStreamCalcSize::Read(void *data, UInt32 size, UInt32 *processedSize))
|
||||
{
|
||||
UInt32 realProcessed = 0;
|
||||
HRESULT result = S_OK;
|
||||
@@ -21,7 +21,7 @@ STDMETHODIMP CSequentialInStreamCalcSize::Read(void *data, UInt32 size, UInt32 *
|
||||
}
|
||||
|
||||
|
||||
STDMETHODIMP COutStreamCalcSize::Write(const void *data, UInt32 size, UInt32 *processedSize)
|
||||
Z7_COM7F_IMF(COutStreamCalcSize::Write(const void *data, UInt32 size, UInt32 *processedSize))
|
||||
{
|
||||
HRESULT result = S_OK;
|
||||
if (_stream)
|
||||
@@ -32,7 +32,7 @@ STDMETHODIMP COutStreamCalcSize::Write(const void *data, UInt32 size, UInt32 *pr
|
||||
return result;
|
||||
}
|
||||
|
||||
STDMETHODIMP COutStreamCalcSize::OutStreamFinish()
|
||||
Z7_COM7F_IMF(COutStreamCalcSize::OutStreamFinish())
|
||||
{
|
||||
HRESULT result = S_OK;
|
||||
if (_stream)
|
||||
@@ -73,7 +73,7 @@ HRESULT CCoder::CheckDataAfterEnd(bool &dataAfterEnd_Error /* , bool &InternalPa
|
||||
if (getInStreamProcessedSize)
|
||||
{
|
||||
UInt64 processed;
|
||||
RINOK(getInStreamProcessedSize->GetInStreamProcessedSize(&processed));
|
||||
RINOK(getInStreamProcessedSize->GetInStreamProcessedSize(&processed))
|
||||
if (processed != (UInt64)(Int64)-1)
|
||||
{
|
||||
const UInt64 size = PackSizes[0];
|
||||
@@ -97,7 +97,7 @@ HRESULT CCoder::CheckDataAfterEnd(bool &dataAfterEnd_Error /* , bool &InternalPa
|
||||
if (!PackSizePointers[i])
|
||||
continue;
|
||||
UInt64 processed;
|
||||
RINOK(getInStreamProcessedSize2->GetInStreamProcessedSize2(i, &processed));
|
||||
RINOK(getInStreamProcessedSize2->GetInStreamProcessedSize2(i, &processed))
|
||||
if (processed != (UInt64)(Int64)-1)
|
||||
{
|
||||
const UInt64 size = PackSizes[i];
|
||||
@@ -343,13 +343,11 @@ void CMixerST::AddCoder(const CCreatedCoder &cod)
|
||||
{
|
||||
IUnknown *unk = (cod.Coder ? (IUnknown *)cod.Coder : (IUnknown *)cod.Coder2);
|
||||
{
|
||||
CMyComPtr<ISequentialInStream> s;
|
||||
unk->QueryInterface(IID_ISequentialInStream, (void**)&s);
|
||||
Z7_DECL_CMyComPtr_QI_FROM(ISequentialInStream, s, unk)
|
||||
c2.CanRead = (s != NULL);
|
||||
}
|
||||
{
|
||||
CMyComPtr<ISequentialOutStream> s;
|
||||
unk->QueryInterface(IID_ISequentialOutStream, (void**)&s);
|
||||
Z7_DECL_CMyComPtr_QI_FROM(ISequentialOutStream, s, unk)
|
||||
c2.CanWrite = (s != NULL);
|
||||
}
|
||||
}
|
||||
@@ -382,8 +380,8 @@ HRESULT CMixerST::GetInStream2(
|
||||
if (!seqInStream)
|
||||
return E_NOTIMPL;
|
||||
|
||||
UInt32 numInStreams = EncodeMode ? 1 : coder.NumStreams;
|
||||
UInt32 startIndex = EncodeMode ? coderIndex : _bi.Coder_to_Stream[coderIndex];
|
||||
const UInt32 numInStreams = EncodeMode ? 1 : coder.NumStreams;
|
||||
const UInt32 startIndex = EncodeMode ? coderIndex : _bi.Coder_to_Stream[coderIndex];
|
||||
|
||||
bool isSet = false;
|
||||
|
||||
@@ -394,8 +392,8 @@ HRESULT CMixerST::GetInStream2(
|
||||
if (setStream)
|
||||
{
|
||||
CMyComPtr<ISequentialInStream> seqInStream2;
|
||||
RINOK(GetInStream(inStreams, /* inSizes, */ startIndex + 0, &seqInStream2));
|
||||
RINOK(setStream->SetInStream(seqInStream2));
|
||||
RINOK(GetInStream(inStreams, /* inSizes, */ startIndex + 0, &seqInStream2))
|
||||
RINOK(setStream->SetInStream(seqInStream2))
|
||||
isSet = true;
|
||||
}
|
||||
}
|
||||
@@ -410,8 +408,8 @@ HRESULT CMixerST::GetInStream2(
|
||||
for (UInt32 i = 0; i < numInStreams; i++)
|
||||
{
|
||||
CMyComPtr<ISequentialInStream> seqInStream2;
|
||||
RINOK(GetInStream(inStreams, /* inSizes, */ startIndex + i, &seqInStream2));
|
||||
RINOK(setStream2->SetInStream2(i, seqInStream2));
|
||||
RINOK(GetInStream(inStreams, /* inSizes, */ startIndex + i, &seqInStream2))
|
||||
RINOK(setStream2->SetInStream2(i, seqInStream2))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -451,7 +449,7 @@ HRESULT CMixerST::GetInStream(
|
||||
return E_INVALIDARG;
|
||||
|
||||
RINOK(GetInStream2(inStreams, /* inSizes, */
|
||||
_bi.Bonds[(unsigned)bond].Get_OutIndex(EncodeMode), &seqInStream));
|
||||
_bi.Bonds[(unsigned)bond].Get_OutIndex(EncodeMode), &seqInStream))
|
||||
|
||||
while (_binderStreams.Size() <= (unsigned)bond)
|
||||
_binderStreams.AddNew();
|
||||
@@ -504,7 +502,7 @@ HRESULT CMixerST::GetOutStream(
|
||||
if (bond < 0)
|
||||
return E_INVALIDARG;
|
||||
|
||||
UInt32 inStreamIndex = _bi.Bonds[(unsigned)bond].Get_InIndex(EncodeMode);
|
||||
const UInt32 inStreamIndex = _bi.Bonds[(unsigned)bond].Get_InIndex(EncodeMode);
|
||||
|
||||
UInt32 coderIndex = inStreamIndex;
|
||||
UInt32 coderStreamIndex = 0;
|
||||
@@ -523,8 +521,8 @@ HRESULT CMixerST::GetOutStream(
|
||||
if (!seqOutStream)
|
||||
return E_NOTIMPL;
|
||||
|
||||
UInt32 numOutStreams = EncodeMode ? coder.NumStreams : 1;
|
||||
UInt32 startIndex = EncodeMode ? _bi.Coder_to_Stream[coderIndex]: coderIndex;
|
||||
const UInt32 numOutStreams = EncodeMode ? coder.NumStreams : 1;
|
||||
const UInt32 startIndex = EncodeMode ? _bi.Coder_to_Stream[coderIndex]: coderIndex;
|
||||
|
||||
bool isSet = false;
|
||||
|
||||
@@ -535,8 +533,8 @@ HRESULT CMixerST::GetOutStream(
|
||||
if (setOutStream)
|
||||
{
|
||||
CMyComPtr<ISequentialOutStream> seqOutStream2;
|
||||
RINOK(GetOutStream(outStreams, /* outSizes, */ startIndex + 0, &seqOutStream2));
|
||||
RINOK(setOutStream->SetOutStream(seqOutStream2));
|
||||
RINOK(GetOutStream(outStreams, /* outSizes, */ startIndex + 0, &seqOutStream2))
|
||||
RINOK(setOutStream->SetOutStream(seqOutStream2))
|
||||
isSet = true;
|
||||
}
|
||||
}
|
||||
@@ -552,8 +550,8 @@ HRESULT CMixerST::GetOutStream(
|
||||
for (UInt32 i = 0; i < numOutStreams; i++)
|
||||
{
|
||||
CMyComPtr<ISequentialOutStream> seqOutStream2;
|
||||
RINOK(GetOutStream(outStreams, startIndex + i, &seqOutStream2));
|
||||
RINOK(setStream2->SetOutStream2(i, seqOutStream2));
|
||||
RINOK(GetOutStream(outStreams, startIndex + i, &seqOutStream2))
|
||||
RINOK(setStream2->SetOutStream2(i, seqOutStream2))
|
||||
}
|
||||
*/
|
||||
}
|
||||
@@ -616,7 +614,7 @@ HRESULT CMixerST::FinishStream(UInt32 streamIndex)
|
||||
if (bond < 0)
|
||||
return E_INVALIDARG;
|
||||
|
||||
UInt32 inStreamIndex = _bi.Bonds[(unsigned)bond].Get_InIndex(EncodeMode);
|
||||
const UInt32 inStreamIndex = _bi.Bonds[(unsigned)bond].Get_InIndex(EncodeMode);
|
||||
|
||||
UInt32 coderIndex = inStreamIndex;
|
||||
UInt32 coderStreamIndex = 0;
|
||||
@@ -639,8 +637,8 @@ HRESULT CMixerST::FinishCoder(UInt32 coderIndex)
|
||||
{
|
||||
CCoder &coder = _coders[coderIndex];
|
||||
|
||||
UInt32 numOutStreams = EncodeMode ? coder.NumStreams : 1;
|
||||
UInt32 startIndex = EncodeMode ? _bi.Coder_to_Stream[coderIndex]: coderIndex;
|
||||
const UInt32 numOutStreams = EncodeMode ? coder.NumStreams : 1;
|
||||
const UInt32 startIndex = EncodeMode ? _bi.Coder_to_Stream[coderIndex]: coderIndex;
|
||||
|
||||
HRESULT res = S_OK;
|
||||
for (unsigned i = 0; i < numOutStreams; i++)
|
||||
@@ -671,7 +669,7 @@ void CMixerST::SelectMainCoder(bool useFirst)
|
||||
if (coder.NumStreams != 1)
|
||||
break;
|
||||
|
||||
UInt32 st = _bi.Coder_to_Stream[ci];
|
||||
const UInt32 st = _bi.Coder_to_Stream[ci];
|
||||
if (_bi.IsStream_in_PackStreams(st))
|
||||
break;
|
||||
const int bond = _bi.FindBond_for_PackStream(st);
|
||||
@@ -706,32 +704,32 @@ HRESULT CMixerST::Code(
|
||||
dataAfterEnd_Error = false;
|
||||
|
||||
_binderStreams.Clear();
|
||||
unsigned ci = MainCoderIndex;
|
||||
const unsigned ci = MainCoderIndex;
|
||||
|
||||
const CCoder &mainCoder = _coders[MainCoderIndex];
|
||||
|
||||
CObjectVector< CMyComPtr<ISequentialInStream> > seqInStreams;
|
||||
CObjectVector< CMyComPtr<ISequentialOutStream> > seqOutStreams;
|
||||
|
||||
UInt32 numInStreams = EncodeMode ? 1 : mainCoder.NumStreams;
|
||||
UInt32 numOutStreams = !EncodeMode ? 1 : mainCoder.NumStreams;
|
||||
const UInt32 numInStreams = EncodeMode ? 1 : mainCoder.NumStreams;
|
||||
const UInt32 numOutStreams = !EncodeMode ? 1 : mainCoder.NumStreams;
|
||||
|
||||
UInt32 startInIndex = EncodeMode ? ci : _bi.Coder_to_Stream[ci];
|
||||
UInt32 startOutIndex = !EncodeMode ? ci : _bi.Coder_to_Stream[ci];
|
||||
const UInt32 startInIndex = EncodeMode ? ci : _bi.Coder_to_Stream[ci];
|
||||
const UInt32 startOutIndex = !EncodeMode ? ci : _bi.Coder_to_Stream[ci];
|
||||
|
||||
UInt32 i;
|
||||
|
||||
for (i = 0; i < numInStreams; i++)
|
||||
{
|
||||
CMyComPtr<ISequentialInStream> seqInStream;
|
||||
RINOK(GetInStream(inStreams, /* inSizes, */ startInIndex + i, &seqInStream));
|
||||
RINOK(GetInStream(inStreams, /* inSizes, */ startInIndex + i, &seqInStream))
|
||||
seqInStreams.Add(seqInStream);
|
||||
}
|
||||
|
||||
for (i = 0; i < numOutStreams; i++)
|
||||
{
|
||||
CMyComPtr<ISequentialOutStream> seqOutStream;
|
||||
RINOK(GetOutStream(outStreams, /* outSizes, */ startOutIndex + i, &seqOutStream));
|
||||
RINOK(GetOutStream(outStreams, /* outSizes, */ startOutIndex + i, &seqOutStream))
|
||||
seqOutStreams.Add(seqOutStream);
|
||||
}
|
||||
|
||||
@@ -755,15 +753,19 @@ HRESULT CMixerST::Code(
|
||||
CMyComPtr<ICompressInitEncoder> initEncoder;
|
||||
coder.QueryInterface(IID_ICompressInitEncoder, (void **)&initEncoder);
|
||||
if (initEncoder)
|
||||
RINOK(initEncoder->InitEncoder());
|
||||
{
|
||||
RINOK(initEncoder->InitEncoder())
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CMyComPtr<ICompressSetOutStreamSize> setOutStreamSize;
|
||||
coder.QueryInterface(IID_ICompressSetOutStreamSize, (void **)&setOutStreamSize);
|
||||
if (setOutStreamSize)
|
||||
{
|
||||
RINOK(setOutStreamSize->SetOutStreamSize(
|
||||
EncodeMode ? coder.PackSizePointers[0] : coder.UnpackSizePointer));
|
||||
EncodeMode ? coder.PackSizePointers[0] : coder.UnpackSizePointer))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -811,7 +813,7 @@ HRESULT CMixerST::Code(
|
||||
|
||||
for (i = 0; i < _coders.Size(); i++)
|
||||
{
|
||||
RINOK(_coders[i].CheckDataAfterEnd(dataAfterEnd_Error /*, InternalPackSizeError */));
|
||||
RINOK(_coders[i].CheckDataAfterEnd(dataAfterEnd_Error /*, InternalPackSizeError */))
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
@@ -834,7 +836,7 @@ HRESULT CMixerST::GetMainUnpackStream(
|
||||
coder.QueryInterface(IID_ICompressSetOutStreamSize, (void **)&setOutStreamSize);
|
||||
if (setOutStreamSize)
|
||||
{
|
||||
RINOK(setOutStreamSize->SetOutStreamSize(coder.UnpackSizePointer));
|
||||
RINOK(setOutStreamSize->SetOutStreamSize(coder.UnpackSizePointer))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -919,7 +921,7 @@ HRESULT CMixerMT::SetBindInfo(const CBindInfo &bindInfo)
|
||||
_streamBinders.Clear();
|
||||
FOR_VECTOR (i, _bi.Bonds)
|
||||
{
|
||||
// RINOK(_streamBinders.AddNew().CreateEvents());
|
||||
// RINOK(_streamBinders.AddNew().CreateEvents())
|
||||
_streamBinders.AddNew();
|
||||
}
|
||||
return S_OK;
|
||||
@@ -946,7 +948,7 @@ HRESULT CMixerMT::ReInit2()
|
||||
{
|
||||
FOR_VECTOR (i, _streamBinders)
|
||||
{
|
||||
RINOK(_streamBinders[i].Create_ReInit());
|
||||
RINOK(_streamBinders[i].Create_ReInit())
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
@@ -986,8 +988,8 @@ HRESULT CMixerMT::Init(ISequentialInStream * const *inStreams, ISequentialOutStr
|
||||
|
||||
UInt32 j;
|
||||
|
||||
unsigned numInStreams = EncodeMode ? 1 : csi.NumStreams;
|
||||
unsigned numOutStreams = EncodeMode ? csi.NumStreams : 1;
|
||||
const unsigned numInStreams = EncodeMode ? 1 : csi.NumStreams;
|
||||
const unsigned numOutStreams = EncodeMode ? csi.NumStreams : 1;
|
||||
|
||||
coderInfo.InStreams.Clear();
|
||||
for (j = 0; j < numInStreams; j++)
|
||||
@@ -1102,8 +1104,8 @@ HRESULT CMixerMT::Code(
|
||||
if (wres != 0)
|
||||
return HRESULT_FROM_WIN32(wres);
|
||||
|
||||
RINOK(ReturnIfError(E_ABORT));
|
||||
RINOK(ReturnIfError(E_OUTOFMEMORY));
|
||||
RINOK(ReturnIfError(E_ABORT))
|
||||
RINOK(ReturnIfError(E_OUTOFMEMORY))
|
||||
|
||||
for (i = 0; i < _coders.Size(); i++)
|
||||
{
|
||||
@@ -1115,7 +1117,7 @@ HRESULT CMixerMT::Code(
|
||||
return result;
|
||||
}
|
||||
|
||||
RINOK(ReturnIfError(S_FALSE));
|
||||
RINOK(ReturnIfError(S_FALSE))
|
||||
|
||||
for (i = 0; i < _coders.Size(); i++)
|
||||
{
|
||||
@@ -1126,7 +1128,7 @@ HRESULT CMixerMT::Code(
|
||||
|
||||
for (i = 0; i < _coders.Size(); i++)
|
||||
{
|
||||
RINOK(_coders[i].CheckDataAfterEnd(dataAfterEnd_Error /* , InternalPackSizeError */));
|
||||
RINOK(_coders[i].CheckDataAfterEnd(dataAfterEnd_Error /* , InternalPackSizeError */))
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// CoderMixer2.h
|
||||
|
||||
#ifndef __CODER_MIXER2_H
|
||||
#define __CODER_MIXER2_H
|
||||
#ifndef ZIP7_INC_CODER_MIXER2_H
|
||||
#define ZIP7_INC_CODER_MIXER2_H
|
||||
|
||||
#include "../../../Common/MyCom.h"
|
||||
#include "../../../Common/MyVector.h"
|
||||
@@ -10,11 +10,11 @@
|
||||
|
||||
#include "../../Common/CreateCoder.h"
|
||||
|
||||
#ifdef _7ZIP_ST
|
||||
#ifdef Z7_ST
|
||||
#define USE_MIXER_ST
|
||||
#else
|
||||
#define USE_MIXER_MT
|
||||
#ifndef _SFX
|
||||
#ifndef Z7_SFX
|
||||
#define USE_MIXER_ST
|
||||
#endif
|
||||
#endif
|
||||
@@ -28,18 +28,13 @@
|
||||
|
||||
#ifdef USE_MIXER_ST
|
||||
|
||||
class CSequentialInStreamCalcSize:
|
||||
public ISequentialInStream,
|
||||
public CMyUnknownImp
|
||||
{
|
||||
public:
|
||||
MY_UNKNOWN_IMP1(ISequentialInStream)
|
||||
|
||||
STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
|
||||
private:
|
||||
Z7_CLASS_IMP_COM_1(
|
||||
CSequentialInStreamCalcSize
|
||||
, ISequentialInStream
|
||||
)
|
||||
bool _wasFinished;
|
||||
CMyComPtr<ISequentialInStream> _stream;
|
||||
UInt64 _size;
|
||||
bool _wasFinished;
|
||||
public:
|
||||
void SetStream(ISequentialInStream *stream) { _stream = stream; }
|
||||
void Init()
|
||||
@@ -53,19 +48,14 @@ public:
|
||||
};
|
||||
|
||||
|
||||
class COutStreamCalcSize:
|
||||
public ISequentialOutStream,
|
||||
public IOutStreamFinish,
|
||||
public CMyUnknownImp
|
||||
{
|
||||
Z7_CLASS_IMP_COM_2(
|
||||
COutStreamCalcSize
|
||||
, ISequentialOutStream
|
||||
, IOutStreamFinish
|
||||
)
|
||||
CMyComPtr<ISequentialOutStream> _stream;
|
||||
UInt64 _size;
|
||||
public:
|
||||
MY_UNKNOWN_IMP2(ISequentialOutStream, IOutStreamFinish)
|
||||
|
||||
STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
|
||||
STDMETHOD(OutStreamFinish)();
|
||||
|
||||
void SetStream(ISequentialOutStream *stream) { _stream = stream; }
|
||||
void ReleaseStream() { _stream.Release(); }
|
||||
void Init() { _size = 0; }
|
||||
@@ -122,7 +112,7 @@ struct CBindInfo
|
||||
bool SetUnpackCoder()
|
||||
{
|
||||
bool isOk = false;
|
||||
FOR_VECTOR(i, Coders)
|
||||
FOR_VECTOR (i, Coders)
|
||||
{
|
||||
if (FindBond_for_UnpackStream(i) < 0)
|
||||
{
|
||||
@@ -142,7 +132,7 @@ struct CBindInfo
|
||||
|
||||
int FindStream_in_PackStreams(UInt32 streamIndex) const
|
||||
{
|
||||
FOR_VECTOR(i, PackStreams)
|
||||
FOR_VECTOR (i, PackStreams)
|
||||
if (PackStreams[i] == streamIndex)
|
||||
return (int)i;
|
||||
return -1;
|
||||
@@ -189,11 +179,12 @@ struct CBindInfo
|
||||
|
||||
class CCoder
|
||||
{
|
||||
CLASS_NO_COPY(CCoder);
|
||||
Z7_CLASS_NO_COPY(CCoder)
|
||||
public:
|
||||
CMyComPtr<ICompressCoder> Coder;
|
||||
CMyComPtr<ICompressCoder2> Coder2;
|
||||
UInt32 NumStreams;
|
||||
bool Finish;
|
||||
|
||||
UInt64 UnpackSize;
|
||||
const UInt64 *UnpackSizePointer;
|
||||
@@ -201,8 +192,6 @@ public:
|
||||
CRecordVector<UInt64> PackSizes;
|
||||
CRecordVector<const UInt64 *> PackSizePointers;
|
||||
|
||||
bool Finish;
|
||||
|
||||
CCoder(): Finish(false) {}
|
||||
|
||||
void SetCoderInfo(const UInt64 *unpackSize, const UInt64 * const *packSizes, bool finish);
|
||||
@@ -251,7 +240,7 @@ public:
|
||||
// , InternalPackSizeError(false)
|
||||
{}
|
||||
|
||||
virtual ~CMixer() {};
|
||||
virtual ~CMixer() {}
|
||||
/*
|
||||
Sequence of calling:
|
||||
|
||||
@@ -323,7 +312,8 @@ class CMixerST:
|
||||
public CMixer,
|
||||
public CMyUnknownImp
|
||||
{
|
||||
CLASS_NO_COPY(CMixerST)
|
||||
Z7_COM_UNKNOWN_IMP_0
|
||||
Z7_CLASS_NO_COPY(CMixerST)
|
||||
|
||||
HRESULT GetInStream2(ISequentialInStream * const *inStreams, /* const UInt64 * const *inSizes, */
|
||||
UInt32 outStreamIndex, ISequentialInStream **inStreamRes);
|
||||
@@ -340,23 +330,21 @@ public:
|
||||
|
||||
CObjectVector<CStBinderStream> _binderStreams;
|
||||
|
||||
MY_UNKNOWN_IMP
|
||||
|
||||
CMixerST(bool encodeMode);
|
||||
~CMixerST();
|
||||
~CMixerST() Z7_DESTRUCTOR_override;
|
||||
|
||||
virtual void AddCoder(const CCreatedCoder &cod);
|
||||
virtual CCoder &GetCoder(unsigned index);
|
||||
virtual void SelectMainCoder(bool useFirst);
|
||||
virtual HRESULT ReInit2();
|
||||
virtual void SetCoderInfo(unsigned coderIndex, const UInt64 *unpackSize, const UInt64 * const *packSizes, bool finish)
|
||||
virtual void AddCoder(const CCreatedCoder &cod) Z7_override;
|
||||
virtual CCoder &GetCoder(unsigned index) Z7_override;
|
||||
virtual void SelectMainCoder(bool useFirst) Z7_override;
|
||||
virtual HRESULT ReInit2() Z7_override;
|
||||
virtual void SetCoderInfo(unsigned coderIndex, const UInt64 *unpackSize, const UInt64 * const *packSizes, bool finish) Z7_override
|
||||
{ _coders[coderIndex].SetCoderInfo(unpackSize, packSizes, finish); }
|
||||
virtual HRESULT Code(
|
||||
ISequentialInStream * const *inStreams,
|
||||
ISequentialOutStream * const *outStreams,
|
||||
ICompressProgressInfo *progress,
|
||||
bool &dataAfterEnd_Error);
|
||||
virtual UInt64 GetBondStreamSize(unsigned bondIndex) const;
|
||||
bool &dataAfterEnd_Error) Z7_override;
|
||||
virtual UInt64 GetBondStreamSize(unsigned bondIndex) const Z7_override;
|
||||
|
||||
HRESULT GetMainUnpackStream(
|
||||
ISequentialInStream * const *inStreams,
|
||||
@@ -372,12 +360,12 @@ public:
|
||||
|
||||
class CCoderMT: public CCoder, public CVirtThread
|
||||
{
|
||||
CLASS_NO_COPY(CCoderMT)
|
||||
Z7_CLASS_NO_COPY(CCoderMT)
|
||||
CRecordVector<ISequentialInStream*> InStreamPointers;
|
||||
CRecordVector<ISequentialOutStream*> OutStreamPointers;
|
||||
|
||||
private:
|
||||
void Execute();
|
||||
virtual void Execute() Z7_override;
|
||||
public:
|
||||
bool EncodeMode;
|
||||
HRESULT Result;
|
||||
@@ -397,7 +385,7 @@ public:
|
||||
|
||||
class CReleaser
|
||||
{
|
||||
CLASS_NO_COPY(CReleaser)
|
||||
Z7_CLASS_NO_COPY(CReleaser)
|
||||
CCoderMT &_c;
|
||||
public:
|
||||
CReleaser(CCoderMT &c): _c(c) {}
|
||||
@@ -405,7 +393,14 @@ public:
|
||||
};
|
||||
|
||||
CCoderMT(): EncodeMode(false) {}
|
||||
virtual ~CCoderMT() { CVirtThread::WaitThreadFinish(); }
|
||||
~CCoderMT() Z7_DESTRUCTOR_override
|
||||
{
|
||||
/* WaitThreadFinish() will be called in ~CVirtThread().
|
||||
But we need WaitThreadFinish() call before CCoder destructor,
|
||||
and before destructors of this class members.
|
||||
*/
|
||||
CVirtThread::WaitThreadFinish();
|
||||
}
|
||||
|
||||
void Code(ICompressProgressInfo *progress);
|
||||
};
|
||||
@@ -416,32 +411,31 @@ class CMixerMT:
|
||||
public CMixer,
|
||||
public CMyUnknownImp
|
||||
{
|
||||
CLASS_NO_COPY(CMixerMT)
|
||||
Z7_COM_UNKNOWN_IMP_0
|
||||
Z7_CLASS_NO_COPY(CMixerMT)
|
||||
|
||||
CObjectVector<CStreamBinder> _streamBinders;
|
||||
|
||||
HRESULT Init(ISequentialInStream * const *inStreams, ISequentialOutStream * const *outStreams);
|
||||
HRESULT ReturnIfError(HRESULT code);
|
||||
|
||||
// virtual ~CMixerMT() {};
|
||||
// virtual ~CMixerMT() {}
|
||||
public:
|
||||
CObjectVector<CCoderMT> _coders;
|
||||
|
||||
MY_UNKNOWN_IMP
|
||||
|
||||
virtual HRESULT SetBindInfo(const CBindInfo &bindInfo);
|
||||
virtual void AddCoder(const CCreatedCoder &cod);
|
||||
virtual CCoder &GetCoder(unsigned index);
|
||||
virtual void SelectMainCoder(bool useFirst);
|
||||
virtual HRESULT ReInit2();
|
||||
virtual void SetCoderInfo(unsigned coderIndex, const UInt64 *unpackSize, const UInt64 * const *packSizes, bool finish)
|
||||
virtual HRESULT SetBindInfo(const CBindInfo &bindInfo) Z7_override;
|
||||
virtual void AddCoder(const CCreatedCoder &cod) Z7_override;
|
||||
virtual CCoder &GetCoder(unsigned index) Z7_override;
|
||||
virtual void SelectMainCoder(bool useFirst) Z7_override;
|
||||
virtual HRESULT ReInit2() Z7_override;
|
||||
virtual void SetCoderInfo(unsigned coderIndex, const UInt64 *unpackSize, const UInt64 * const *packSizes, bool finish) Z7_override
|
||||
{ _coders[coderIndex].SetCoderInfo(unpackSize, packSizes, finish); }
|
||||
virtual HRESULT Code(
|
||||
ISequentialInStream * const *inStreams,
|
||||
ISequentialOutStream * const *outStreams,
|
||||
ICompressProgressInfo *progress,
|
||||
bool &dataAfterEnd_Error);
|
||||
virtual UInt64 GetBondStreamSize(unsigned bondIndex) const;
|
||||
bool &dataAfterEnd_Error) Z7_override;
|
||||
virtual UInt64 GetBondStreamSize(unsigned bondIndex) const Z7_override;
|
||||
|
||||
CMixerMT(bool encodeMode): CMixer(encodeMode) {}
|
||||
};
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#include "DummyOutStream.h"
|
||||
|
||||
STDMETHODIMP CDummyOutStream::Write(const void *data, UInt32 size, UInt32 *processedSize)
|
||||
Z7_COM7F_IMF(CDummyOutStream::Write(const void *data, UInt32 size, UInt32 *processedSize))
|
||||
{
|
||||
UInt32 realProcessedSize = size;
|
||||
HRESULT res = S_OK;
|
||||
|
||||
@@ -1,24 +1,22 @@
|
||||
// DummyOutStream.h
|
||||
|
||||
#ifndef __DUMMY_OUT_STREAM_H
|
||||
#define __DUMMY_OUT_STREAM_H
|
||||
#ifndef ZIP7_INC_DUMMY_OUT_STREAM_H
|
||||
#define ZIP7_INC_DUMMY_OUT_STREAM_H
|
||||
|
||||
#include "../../../Common/MyCom.h"
|
||||
|
||||
#include "../../IStream.h"
|
||||
|
||||
class CDummyOutStream:
|
||||
public ISequentialOutStream,
|
||||
public CMyUnknownImp
|
||||
{
|
||||
Z7_CLASS_IMP_NOQIB_1(
|
||||
CDummyOutStream
|
||||
, ISequentialOutStream
|
||||
)
|
||||
CMyComPtr<ISequentialOutStream> _stream;
|
||||
UInt64 _size;
|
||||
public:
|
||||
void SetStream(ISequentialOutStream *outStream) { _stream = outStream; }
|
||||
void ReleaseStream() { _stream.Release(); }
|
||||
void Init() { _size = 0; }
|
||||
MY_UNKNOWN_IMP
|
||||
STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
|
||||
UInt64 GetSize() const { return _size; }
|
||||
};
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ HRESULT FindSignatureInStream(ISequentialInStream *stream,
|
||||
{
|
||||
resPos = 0;
|
||||
CByteBuffer byteBuffer2(signatureSize);
|
||||
RINOK(ReadStream_FALSE(stream, byteBuffer2, signatureSize));
|
||||
RINOK(ReadStream_FALSE(stream, byteBuffer2, signatureSize))
|
||||
|
||||
if (memcmp(byteBuffer2, signature, signatureSize) == 0)
|
||||
return S_OK;
|
||||
@@ -29,23 +29,23 @@ HRESULT FindSignatureInStream(ISequentialInStream *stream,
|
||||
resPos = 1;
|
||||
for (;;)
|
||||
{
|
||||
if (limit != NULL)
|
||||
if (limit)
|
||||
if (resPos > *limit)
|
||||
return S_FALSE;
|
||||
do
|
||||
{
|
||||
UInt32 numReadBytes = kBufferSize - numPrevBytes;
|
||||
const UInt32 numReadBytes = kBufferSize - numPrevBytes;
|
||||
UInt32 processedSize;
|
||||
RINOK(stream->Read(buffer + numPrevBytes, numReadBytes, &processedSize));
|
||||
RINOK(stream->Read(buffer + numPrevBytes, numReadBytes, &processedSize))
|
||||
numPrevBytes += processedSize;
|
||||
if (processedSize == 0)
|
||||
return S_FALSE;
|
||||
}
|
||||
while (numPrevBytes < signatureSize);
|
||||
UInt32 numTests = numPrevBytes - signatureSize + 1;
|
||||
const UInt32 numTests = numPrevBytes - signatureSize + 1;
|
||||
for (UInt32 pos = 0; pos < numTests; pos++)
|
||||
{
|
||||
Byte b = signature[0];
|
||||
const Byte b = signature[0];
|
||||
for (; buffer[pos] != b && pos < numTests; pos++);
|
||||
if (pos == numTests)
|
||||
break;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// FindSignature.h
|
||||
|
||||
#ifndef __FIND_SIGNATURE_H
|
||||
#define __FIND_SIGNATURE_H
|
||||
#ifndef ZIP7_INC_FIND_SIGNATURE_H
|
||||
#define ZIP7_INC_FIND_SIGNATURE_H
|
||||
|
||||
#include "../../IStream.h"
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ bool CCommonMethodProps::SetCommonProperty(const UString &name, const PROPVARIAN
|
||||
|
||||
if (name.IsPrefixedBy_Ascii_NoCase("mt"))
|
||||
{
|
||||
#ifndef _7ZIP_ST
|
||||
#ifndef Z7_ST
|
||||
_numThreads = _numProcessors;
|
||||
_numThreads_WasForced = false;
|
||||
hres = ParseMtProp2(name.Ptr(2), value, _numThreads, _numThreads_WasForced);
|
||||
@@ -112,7 +112,7 @@ bool CCommonMethodProps::SetCommonProperty(const UString &name, const PROPVARIAN
|
||||
}
|
||||
|
||||
|
||||
#ifndef EXTRACT_ONLY
|
||||
#ifndef Z7_EXTRACT_ONLY
|
||||
|
||||
static void SetMethodProp32(CMethodProps &m, PROPID propID, UInt32 value)
|
||||
{
|
||||
@@ -127,7 +127,7 @@ void CMultiMethodProps::SetGlobalLevelTo(COneMethodInfo &oneMethodInfo) const
|
||||
SetMethodProp32(oneMethodInfo, NCoderPropID::kLevel, (UInt32)level);
|
||||
}
|
||||
|
||||
#ifndef _7ZIP_ST
|
||||
#ifndef Z7_ST
|
||||
|
||||
static void SetMethodProp32_Replace(CMethodProps &m, PROPID propID, UInt32 value)
|
||||
{
|
||||
@@ -151,7 +151,7 @@ void CMultiMethodProps::SetMethodThreadsTo_Replace(CMethodProps &oneMethodInfo,
|
||||
SetMethodProp32_Replace(oneMethodInfo, NCoderPropID::kNumThreads, numThreads);
|
||||
}
|
||||
|
||||
#endif // _7ZIP_ST
|
||||
#endif // Z7_ST
|
||||
|
||||
|
||||
void CMultiMethodProps::InitMulti()
|
||||
@@ -189,7 +189,7 @@ HRESULT CMultiMethodProps::SetProperty(const wchar_t *nameSpec, const PROPVARIAN
|
||||
{
|
||||
name.Delete(0, 2);
|
||||
UInt32 v = 9;
|
||||
RINOK(ParsePropToUInt32(name, value, v));
|
||||
RINOK(ParsePropToUInt32(name, value, v))
|
||||
_analysisLevel = (int)v;
|
||||
return S_OK;
|
||||
}
|
||||
@@ -208,13 +208,13 @@ HRESULT CMultiMethodProps::SetProperty(const wchar_t *nameSpec, const PROPVARIAN
|
||||
}
|
||||
|
||||
UInt32 number;
|
||||
unsigned index = ParseStringToUInt32(name, number);
|
||||
UString realName = name.Ptr(index);
|
||||
const unsigned index = ParseStringToUInt32(name, number);
|
||||
const UString realName = name.Ptr(index);
|
||||
if (index == 0)
|
||||
{
|
||||
if (name.IsEqualTo("f"))
|
||||
{
|
||||
HRESULT res = PROPVARIANT_to_bool(value, _autoFilter);
|
||||
const HRESULT res = PROPVARIANT_to_bool(value, _autoFilter);
|
||||
if (res == S_OK)
|
||||
return res;
|
||||
if (value.vt != VT_BSTR)
|
||||
@@ -224,7 +224,7 @@ HRESULT CMultiMethodProps::SetProperty(const wchar_t *nameSpec, const PROPVARIAN
|
||||
number = 0;
|
||||
}
|
||||
if (number > 64)
|
||||
return E_FAIL;
|
||||
return E_INVALIDARG;
|
||||
for (unsigned j = _methods.Size(); j <= number; j++)
|
||||
_methods.AddNew();
|
||||
return _methods[number].ParseMethodFromPROPVARIANT(realName, value);
|
||||
@@ -250,7 +250,7 @@ HRESULT CSingleMethodProps::SetProperty(const wchar_t *name2, const PROPVARIANT
|
||||
if (name.IsPrefixedBy_Ascii_NoCase("x"))
|
||||
{
|
||||
UInt32 a = 9;
|
||||
RINOK(ParsePropToUInt32(name.Ptr(1), value, a));
|
||||
RINOK(ParsePropToUInt32(name.Ptr(1), value, a))
|
||||
_level = a;
|
||||
AddProp_Level(a);
|
||||
// processed = true;
|
||||
@@ -264,7 +264,7 @@ HRESULT CSingleMethodProps::SetProperty(const wchar_t *name2, const PROPVARIANT
|
||||
return S_OK;
|
||||
}
|
||||
}
|
||||
RINOK(ParseMethodFromPROPVARIANT(name, value));
|
||||
RINOK(ParseMethodFromPROPVARIANT(name, value))
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@@ -275,7 +275,7 @@ HRESULT CSingleMethodProps::SetProperties(const wchar_t * const *names, const PR
|
||||
|
||||
for (UInt32 i = 0; i < numProps; i++)
|
||||
{
|
||||
RINOK(SetProperty(names[i], values[i]));
|
||||
RINOK(SetProperty(names[i], values[i]))
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
@@ -286,7 +286,7 @@ HRESULT CSingleMethodProps::SetProperties(const wchar_t * const *names, const PR
|
||||
|
||||
static HRESULT PROPVARIANT_to_BoolPair(const PROPVARIANT &prop, CBoolPair &dest)
|
||||
{
|
||||
RINOK(PROPVARIANT_to_bool(prop, dest.Val));
|
||||
RINOK(PROPVARIANT_to_bool(prop, dest.Val))
|
||||
dest.Def = true;
|
||||
return S_OK;
|
||||
}
|
||||
@@ -300,7 +300,7 @@ HRESULT CHandlerTimeOptions::Parse(const UString &name, const PROPVARIANT &prop,
|
||||
if (name.IsPrefixedBy_Ascii_NoCase("tp"))
|
||||
{
|
||||
UInt32 v = 0;
|
||||
RINOK(ParsePropToUInt32(name.Ptr(2), prop, v));
|
||||
RINOK(ParsePropToUInt32(name.Ptr(2), prop, v))
|
||||
Prec = v;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// HandlerOut.h
|
||||
|
||||
#ifndef __HANDLER_OUT_H
|
||||
#define __HANDLER_OUT_H
|
||||
#ifndef ZIP7_INC_HANDLER_OUT_H
|
||||
#define ZIP7_INC_HANDLER_OUT_H
|
||||
|
||||
#include "../../../Windows/System.h"
|
||||
|
||||
@@ -17,7 +17,7 @@ protected:
|
||||
void InitCommon()
|
||||
{
|
||||
// _Write_MTime = true;
|
||||
#ifndef _7ZIP_ST
|
||||
#ifndef Z7_ST
|
||||
_numProcessors = _numThreads = NWindows::NSystem::GetNumberOfProcessors();
|
||||
_numThreads_WasForced = false;
|
||||
#endif
|
||||
@@ -46,7 +46,7 @@ protected:
|
||||
}
|
||||
|
||||
public:
|
||||
#ifndef _7ZIP_ST
|
||||
#ifndef Z7_ST
|
||||
UInt32 _numThreads;
|
||||
UInt32 _numProcessors;
|
||||
bool _numThreads_WasForced;
|
||||
@@ -63,7 +63,7 @@ public:
|
||||
};
|
||||
|
||||
|
||||
#ifndef EXTRACT_ONLY
|
||||
#ifndef Z7_EXTRACT_ONLY
|
||||
|
||||
class CMultiMethodProps: public CCommonMethodProps
|
||||
{
|
||||
@@ -80,7 +80,7 @@ public:
|
||||
|
||||
void SetGlobalLevelTo(COneMethodInfo &oneMethodInfo) const;
|
||||
|
||||
#ifndef _7ZIP_ST
|
||||
#ifndef Z7_ST
|
||||
static void SetMethodThreadsTo_IfNotFinded(CMethodProps &props, UInt32 numThreads);
|
||||
static void SetMethodThreadsTo_Replace(CMethodProps &props, UInt32 numThreads);
|
||||
#endif
|
||||
|
||||
@@ -4,22 +4,33 @@
|
||||
|
||||
#include "InStreamWithCRC.h"
|
||||
|
||||
STDMETHODIMP CSequentialInStreamWithCRC::Read(void *data, UInt32 size, UInt32 *processedSize)
|
||||
Z7_COM7F_IMF(CSequentialInStreamWithCRC::Read(void *data, UInt32 size, UInt32 *processedSize))
|
||||
{
|
||||
UInt32 realProcessed = 0;
|
||||
HRESULT result = S_OK;
|
||||
if (_stream)
|
||||
result = _stream->Read(data, size, &realProcessed);
|
||||
_size += realProcessed;
|
||||
if (size != 0 && realProcessed == 0)
|
||||
_wasFinished = true;
|
||||
_crc = CrcUpdate(_crc, data, realProcessed);
|
||||
if (size != 0)
|
||||
{
|
||||
if (_stream)
|
||||
result = _stream->Read(data, size, &realProcessed);
|
||||
_size += realProcessed;
|
||||
if (realProcessed == 0)
|
||||
_wasFinished = true;
|
||||
else
|
||||
_crc = CrcUpdate(_crc, data, realProcessed);
|
||||
}
|
||||
if (processedSize)
|
||||
*processedSize = realProcessed;
|
||||
return result;
|
||||
}
|
||||
|
||||
STDMETHODIMP CInStreamWithCRC::Read(void *data, UInt32 size, UInt32 *processedSize)
|
||||
Z7_COM7F_IMF(CSequentialInStreamWithCRC::GetSize(UInt64 *size))
|
||||
{
|
||||
*size = _fullSize;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
Z7_COM7F_IMF(CInStreamWithCRC::Read(void *data, UInt32 size, UInt32 *processedSize))
|
||||
{
|
||||
UInt32 realProcessed = 0;
|
||||
HRESULT result = S_OK;
|
||||
@@ -36,7 +47,7 @@ STDMETHODIMP CInStreamWithCRC::Read(void *data, UInt32 size, UInt32 *processedSi
|
||||
return result;
|
||||
}
|
||||
|
||||
STDMETHODIMP CInStreamWithCRC::Seek(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition)
|
||||
Z7_COM7F_IMF(CInStreamWithCRC::Seek(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition))
|
||||
{
|
||||
if (seekOrigin != STREAM_SEEK_SET || offset != 0)
|
||||
return E_FAIL;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// InStreamWithCRC.h
|
||||
|
||||
#ifndef __IN_STREAM_WITH_CRC_H
|
||||
#define __IN_STREAM_WITH_CRC_H
|
||||
#ifndef ZIP7_INC_IN_STREAM_WITH_CRC_H
|
||||
#define ZIP7_INC_IN_STREAM_WITH_CRC_H
|
||||
|
||||
#include "../../../../C/7zCrc.h"
|
||||
|
||||
@@ -9,26 +9,29 @@
|
||||
|
||||
#include "../../IStream.h"
|
||||
|
||||
class CSequentialInStreamWithCRC:
|
||||
public ISequentialInStream,
|
||||
public CMyUnknownImp
|
||||
{
|
||||
public:
|
||||
MY_UNKNOWN_IMP
|
||||
|
||||
STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
|
||||
private:
|
||||
Z7_CLASS_IMP_NOQIB_2(
|
||||
CSequentialInStreamWithCRC
|
||||
, ISequentialInStream
|
||||
, IStreamGetSize
|
||||
)
|
||||
CMyComPtr<ISequentialInStream> _stream;
|
||||
UInt64 _size;
|
||||
UInt32 _crc;
|
||||
bool _wasFinished;
|
||||
UInt64 _fullSize;
|
||||
public:
|
||||
void SetStream(ISequentialInStream *stream) { _stream = stream; }
|
||||
|
||||
CSequentialInStreamWithCRC():
|
||||
_fullSize((UInt64)(Int64)-1)
|
||||
{}
|
||||
|
||||
void SetStream(ISequentialInStream *stream) { _stream = stream; }
|
||||
void SetFullSize(UInt64 fullSize) { _fullSize = fullSize; }
|
||||
void Init()
|
||||
{
|
||||
_size = 0;
|
||||
_wasFinished = false;
|
||||
_crc = CRC_INIT_VAL;
|
||||
_wasFinished = false;
|
||||
}
|
||||
void ReleaseStream() { _stream.Release(); }
|
||||
UInt32 GetCRC() const { return CRC_GET_DIGEST(_crc); }
|
||||
@@ -36,22 +39,19 @@ public:
|
||||
bool WasFinished() const { return _wasFinished; }
|
||||
};
|
||||
|
||||
class CInStreamWithCRC:
|
||||
public IInStream,
|
||||
public CMyUnknownImp
|
||||
{
|
||||
public:
|
||||
MY_UNKNOWN_IMP1(IInStream)
|
||||
|
||||
STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
|
||||
STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition);
|
||||
private:
|
||||
Z7_CLASS_IMP_COM_1(
|
||||
CInStreamWithCRC,
|
||||
IInStream
|
||||
)
|
||||
Z7_IFACE_COM7_IMP(ISequentialInStream)
|
||||
|
||||
CMyComPtr<IInStream> _stream;
|
||||
UInt64 _size;
|
||||
UInt32 _crc;
|
||||
// bool _wasFinished;
|
||||
public:
|
||||
void SetStream(IInStream *stream) { _stream = stream; }
|
||||
void SetStream(IInStream *stream) { _stream = stream; }
|
||||
void Init()
|
||||
{
|
||||
_size = 0;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Archive/Common/ItemNameUtils.h
|
||||
|
||||
#ifndef __ARCHIVE_ITEM_NAME_UTILS_H
|
||||
#define __ARCHIVE_ITEM_NAME_UTILS_H
|
||||
#ifndef ZIP7_INC_ARCHIVE_ITEM_NAME_UTILS_H
|
||||
#define ZIP7_INC_ARCHIVE_ITEM_NAME_UTILS_H
|
||||
|
||||
#include "../../../Common/MyString.h"
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#include "MultiStream.h"
|
||||
|
||||
STDMETHODIMP CMultiStream::Read(void *data, UInt32 size, UInt32 *processedSize)
|
||||
Z7_COM7F_IMF(CMultiStream::Read(void *data, UInt32 size, UInt32 *processedSize))
|
||||
{
|
||||
if (processedSize)
|
||||
*processedSize = 0;
|
||||
@@ -23,10 +23,7 @@ STDMETHODIMP CMultiStream::Read(void *data, UInt32 size, UInt32 *processedSize)
|
||||
else if (_pos >= m.GlobalOffset + m.Size)
|
||||
left = mid + 1;
|
||||
else
|
||||
{
|
||||
_streamIndex = mid;
|
||||
break;
|
||||
}
|
||||
mid = (left + right) / 2;
|
||||
}
|
||||
_streamIndex = mid;
|
||||
@@ -36,12 +33,14 @@ STDMETHODIMP CMultiStream::Read(void *data, UInt32 size, UInt32 *processedSize)
|
||||
UInt64 localPos = _pos - s.GlobalOffset;
|
||||
if (localPos != s.LocalPos)
|
||||
{
|
||||
RINOK(s.Stream->Seek((Int64)localPos, STREAM_SEEK_SET, &s.LocalPos));
|
||||
RINOK(s.Stream->Seek((Int64)localPos, STREAM_SEEK_SET, &s.LocalPos))
|
||||
}
|
||||
UInt64 rem = s.Size - localPos;
|
||||
if (size > rem)
|
||||
size = (UInt32)rem;
|
||||
HRESULT result = s.Stream->Read(data, size, &size);
|
||||
{
|
||||
const UInt64 rem = s.Size - localPos;
|
||||
if (size > rem)
|
||||
size = (UInt32)rem;
|
||||
}
|
||||
const HRESULT result = s.Stream->Read(data, size, &size);
|
||||
_pos += size;
|
||||
s.LocalPos += size;
|
||||
if (processedSize)
|
||||
@@ -49,7 +48,7 @@ STDMETHODIMP CMultiStream::Read(void *data, UInt32 size, UInt32 *processedSize)
|
||||
return result;
|
||||
}
|
||||
|
||||
STDMETHODIMP CMultiStream::Seek(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition)
|
||||
Z7_COM7F_IMF(CMultiStream::Seek(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition))
|
||||
{
|
||||
switch (seekOrigin)
|
||||
{
|
||||
@@ -72,6 +71,9 @@ class COutVolumeStream:
|
||||
public ISequentialOutStream,
|
||||
public CMyUnknownImp
|
||||
{
|
||||
Z7_COM_UNKNOWN_IMP_0
|
||||
Z7_IFACE_COM7_IMP(ISequentialOutStream)
|
||||
|
||||
unsigned _volIndex;
|
||||
UInt64 _volSize;
|
||||
UInt64 _curPos;
|
||||
@@ -80,8 +82,6 @@ class COutVolumeStream:
|
||||
CCRC _crc;
|
||||
|
||||
public:
|
||||
MY_UNKNOWN_IMP
|
||||
|
||||
CFileItem _file;
|
||||
CUpdateOptions _options;
|
||||
CMyComPtr<IArchiveUpdateCallback2> VolumeCallback;
|
||||
@@ -98,7 +98,6 @@ public:
|
||||
}
|
||||
|
||||
HRESULT Flush();
|
||||
STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
|
||||
};
|
||||
|
||||
HRESULT COutVolumeStream::Flush()
|
||||
@@ -107,7 +106,7 @@ HRESULT COutVolumeStream::Flush()
|
||||
{
|
||||
_file.UnPackSize = _curPos;
|
||||
_file.FileCRC = _crc.GetDigest();
|
||||
RINOK(WriteVolumeHeader(_archive, _file, _options));
|
||||
RINOK(WriteVolumeHeader(_archive, _file, _options))
|
||||
_archive.Close();
|
||||
_volumeStream.Release();
|
||||
_file.StartPos += _file.UnPackSize;
|
||||
@@ -117,7 +116,10 @@ HRESULT COutVolumeStream::Flush()
|
||||
*/
|
||||
|
||||
/*
|
||||
STDMETHODIMP COutMultiStream::Write(const void *data, UInt32 size, UInt32 *processedSize)
|
||||
|
||||
#include "../../../Common/Defs.h"
|
||||
|
||||
Z7_COM7F_IMF(COutMultiStream::Write(const void *data, UInt32 size, UInt32 *processedSize))
|
||||
{
|
||||
if (processedSize)
|
||||
*processedSize = 0;
|
||||
@@ -126,8 +128,8 @@ STDMETHODIMP COutMultiStream::Write(const void *data, UInt32 size, UInt32 *proce
|
||||
if (_streamIndex >= Streams.Size())
|
||||
{
|
||||
CSubStreamInfo subStream;
|
||||
RINOK(VolumeCallback->GetVolumeSize(Streams.Size(), &subStream.Size));
|
||||
RINOK(VolumeCallback->GetVolumeStream(Streams.Size(), &subStream.Stream));
|
||||
RINOK(VolumeCallback->GetVolumeSize(Streams.Size(), &subStream.Size))
|
||||
RINOK(VolumeCallback->GetVolumeStream(Streams.Size(), &subStream.Stream))
|
||||
subStream.Pos = 0;
|
||||
Streams.Add(subStream);
|
||||
continue;
|
||||
@@ -142,15 +144,15 @@ STDMETHODIMP COutMultiStream::Write(const void *data, UInt32 size, UInt32 *proce
|
||||
if (_offsetPos != subStream.Pos)
|
||||
{
|
||||
CMyComPtr<IOutStream> outStream;
|
||||
RINOK(subStream.Stream.QueryInterface(IID_IOutStream, &outStream));
|
||||
RINOK(outStream->Seek(_offsetPos, STREAM_SEEK_SET, NULL));
|
||||
RINOK(subStream.Stream.QueryInterface(IID_IOutStream, &outStream))
|
||||
RINOK(outStream->Seek((Int64)_offsetPos, STREAM_SEEK_SET, NULL))
|
||||
subStream.Pos = _offsetPos;
|
||||
}
|
||||
|
||||
UInt32 curSize = (UInt32)MyMin((UInt64)size, subStream.Size - subStream.Pos);
|
||||
const UInt32 curSize = (UInt32)MyMin((UInt64)size, subStream.Size - subStream.Pos);
|
||||
UInt32 realProcessed;
|
||||
RINOK(subStream.Stream->Write(data, curSize, &realProcessed));
|
||||
data = (void *)((Byte *)data + realProcessed);
|
||||
RINOK(subStream.Stream->Write(data, curSize, &realProcessed))
|
||||
data = (const void *)((const Byte *)data + realProcessed);
|
||||
size -= realProcessed;
|
||||
subStream.Pos += realProcessed;
|
||||
_offsetPos += realProcessed;
|
||||
@@ -170,7 +172,7 @@ STDMETHODIMP COutMultiStream::Write(const void *data, UInt32 size, UInt32 *proce
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP COutMultiStream::Seek(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition)
|
||||
Z7_COM7F_IMF(COutMultiStream::Seek(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition))
|
||||
{
|
||||
switch (seekOrigin)
|
||||
{
|
||||
@@ -181,11 +183,11 @@ STDMETHODIMP COutMultiStream::Seek(Int64 offset, UInt32 seekOrigin, UInt64 *newP
|
||||
}
|
||||
if (offset < 0)
|
||||
return HRESULT_WIN32_ERROR_NEGATIVE_SEEK;
|
||||
_absPos = offset;
|
||||
_absPos = (UInt64)offset;
|
||||
_offsetPos = _absPos;
|
||||
_streamIndex = 0;
|
||||
if (newPosition)
|
||||
*newPosition = offset;
|
||||
*newPosition = (UInt64)offset;
|
||||
return S_OK;
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -1,20 +1,23 @@
|
||||
// MultiStream.h
|
||||
|
||||
#ifndef __MULTI_STREAM_H
|
||||
#define __MULTI_STREAM_H
|
||||
#ifndef ZIP7_INC_MULTI_STREAM_H
|
||||
#define ZIP7_INC_MULTI_STREAM_H
|
||||
|
||||
#include "../../../Common/MyCom.h"
|
||||
#include "../../../Common/MyVector.h"
|
||||
|
||||
#include "../../IStream.h"
|
||||
#include "../../Archive/IArchive.h"
|
||||
|
||||
class CMultiStream:
|
||||
public IInStream,
|
||||
public CMyUnknownImp
|
||||
{
|
||||
Z7_CLASS_IMP_COM_1(
|
||||
CMultiStream
|
||||
, IInStream
|
||||
)
|
||||
Z7_IFACE_COM7_IMP(ISequentialInStream)
|
||||
|
||||
unsigned _streamIndex;
|
||||
UInt64 _pos;
|
||||
UInt64 _totalLength;
|
||||
unsigned _streamIndex;
|
||||
|
||||
public:
|
||||
|
||||
@@ -24,12 +27,12 @@ public:
|
||||
UInt64 Size;
|
||||
UInt64 GlobalOffset;
|
||||
UInt64 LocalPos;
|
||||
|
||||
CSubStreamInfo(): Size(0), GlobalOffset(0), LocalPos(0) {}
|
||||
};
|
||||
|
||||
|
||||
CMyComPtr<IArchiveUpdateCallbackFile> updateCallbackFile;
|
||||
CObjectVector<CSubStreamInfo> Streams;
|
||||
|
||||
|
||||
HRESULT Init()
|
||||
{
|
||||
UInt64 total = 0;
|
||||
@@ -37,26 +40,27 @@ public:
|
||||
{
|
||||
CSubStreamInfo &s = Streams[i];
|
||||
s.GlobalOffset = total;
|
||||
total += Streams[i].Size;
|
||||
RINOK(s.Stream->Seek(0, STREAM_SEEK_CUR, &s.LocalPos));
|
||||
total += s.Size;
|
||||
s.LocalPos = 0;
|
||||
{
|
||||
// it was already set to start
|
||||
// RINOK(InStream_GetPos(s.Stream, s.LocalPos));
|
||||
}
|
||||
}
|
||||
_totalLength = total;
|
||||
_pos = 0;
|
||||
_streamIndex = 0;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
MY_UNKNOWN_IMP1(IInStream)
|
||||
|
||||
STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
|
||||
STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition);
|
||||
};
|
||||
|
||||
/*
|
||||
class COutMultiStream:
|
||||
public IOutStream,
|
||||
public CMyUnknownImp
|
||||
{
|
||||
Z7_CLASS_IMP_COM_1(
|
||||
COutMultiStream,
|
||||
IOutStream
|
||||
)
|
||||
Z7_IFACE_COM7_IMP(ISequentialOutStream)
|
||||
|
||||
unsigned _streamIndex; // required stream
|
||||
UInt64 _offsetPos; // offset from start of _streamIndex index
|
||||
UInt64 _absPos;
|
||||
@@ -78,11 +82,6 @@ public:
|
||||
_absPos = 0;
|
||||
_length = 0;
|
||||
}
|
||||
|
||||
MY_UNKNOWN_IMP1(IOutStream)
|
||||
|
||||
STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
|
||||
STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition);
|
||||
};
|
||||
*/
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#include "OutStreamWithCRC.h"
|
||||
|
||||
STDMETHODIMP COutStreamWithCRC::Write(const void *data, UInt32 size, UInt32 *processedSize)
|
||||
Z7_COM7F_IMF(COutStreamWithCRC::Write(const void *data, UInt32 size, UInt32 *processedSize))
|
||||
{
|
||||
HRESULT result = S_OK;
|
||||
if (_stream)
|
||||
@@ -12,7 +12,7 @@ STDMETHODIMP COutStreamWithCRC::Write(const void *data, UInt32 size, UInt32 *pro
|
||||
if (_calculate)
|
||||
_crc = CrcUpdate(_crc, data, size);
|
||||
_size += size;
|
||||
if (processedSize != NULL)
|
||||
if (processedSize)
|
||||
*processedSize = size;
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// OutStreamWithCRC.h
|
||||
|
||||
#ifndef __OUT_STREAM_WITH_CRC_H
|
||||
#define __OUT_STREAM_WITH_CRC_H
|
||||
#ifndef ZIP7_INC_OUT_STREAM_WITH_CRC_H
|
||||
#define ZIP7_INC_OUT_STREAM_WITH_CRC_H
|
||||
|
||||
#include "../../../../C/7zCrc.h"
|
||||
|
||||
@@ -9,17 +9,15 @@
|
||||
|
||||
#include "../../IStream.h"
|
||||
|
||||
class COutStreamWithCRC:
|
||||
public ISequentialOutStream,
|
||||
public CMyUnknownImp
|
||||
{
|
||||
Z7_CLASS_IMP_NOQIB_1(
|
||||
COutStreamWithCRC
|
||||
, ISequentialOutStream
|
||||
)
|
||||
CMyComPtr<ISequentialOutStream> _stream;
|
||||
UInt64 _size;
|
||||
UInt32 _crc;
|
||||
bool _calculate;
|
||||
public:
|
||||
MY_UNKNOWN_IMP
|
||||
STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
|
||||
void SetStream(ISequentialOutStream *stream) { _stream = stream; }
|
||||
void ReleaseStream() { _stream.Release(); }
|
||||
void Init(bool calculate = true)
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#include "OutStreamWithSha1.h"
|
||||
|
||||
STDMETHODIMP COutStreamWithSha1::Write(const void *data, UInt32 size, UInt32 *processedSize)
|
||||
Z7_COM7F_IMF(COutStreamWithSha1::Write(const void *data, UInt32 size, UInt32 *processedSize))
|
||||
{
|
||||
HRESULT result = S_OK;
|
||||
if (_stream)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// OutStreamWithSha1.h
|
||||
|
||||
#ifndef __OUT_STREAM_WITH_SHA1_H
|
||||
#define __OUT_STREAM_WITH_SHA1_H
|
||||
#ifndef ZIP7_INC_OUT_STREAM_WITH_SHA1_H
|
||||
#define ZIP7_INC_OUT_STREAM_WITH_SHA1_H
|
||||
|
||||
#include "../../../../C/Sha1.h"
|
||||
|
||||
@@ -10,23 +10,19 @@
|
||||
|
||||
#include "../../IStream.h"
|
||||
|
||||
class COutStreamWithSha1:
|
||||
public ISequentialOutStream,
|
||||
public CMyUnknownImp
|
||||
{
|
||||
Z7_CLASS_IMP_NOQIB_1(
|
||||
COutStreamWithSha1
|
||||
, ISequentialOutStream
|
||||
)
|
||||
CMyComPtr<ISequentialOutStream> _stream;
|
||||
UInt64 _size;
|
||||
// CSha1 _sha;
|
||||
bool _calculate;
|
||||
CAlignedBuffer _sha;
|
||||
CAlignedBuffer1 _sha;
|
||||
|
||||
CSha1 *Sha() { return (CSha1 *)(void *)(Byte *)_sha; }
|
||||
public:
|
||||
MY_UNKNOWN_IMP
|
||||
|
||||
COutStreamWithSha1(): _sha(sizeof(CSha1)) {}
|
||||
|
||||
STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
|
||||
void SetStream(ISequentialOutStream *stream) { _stream = stream; }
|
||||
void ReleaseStream() { _stream.Release(); }
|
||||
void Init(bool calculate = true)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// ParseProperties.h
|
||||
|
||||
#ifndef __PARSE_PROPERTIES_H
|
||||
#define __PARSE_PROPERTIES_H
|
||||
#ifndef ZIP7_INC_PARSE_PROPERTIES_H
|
||||
#define ZIP7_INC_PARSE_PROPERTIES_H
|
||||
|
||||
#endif
|
||||
|
||||
@@ -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