summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/lzma/CPP/7zip/Archive/Common
diff options
context:
space:
mode:
Diffstat (limited to '3rdparty/lzma/CPP/7zip/Archive/Common')
-rw-r--r--3rdparty/lzma/CPP/7zip/Archive/Common/CoderMixer2.cpp262
-rw-r--r--3rdparty/lzma/CPP/7zip/Archive/Common/CoderMixer2.h134
-rw-r--r--3rdparty/lzma/CPP/7zip/Archive/Common/DummyOutStream.cpp2
-rw-r--r--3rdparty/lzma/CPP/7zip/Archive/Common/DummyOutStream.h14
-rw-r--r--3rdparty/lzma/CPP/7zip/Archive/Common/HandlerOut.cpp288
-rw-r--r--3rdparty/lzma/CPP/7zip/Archive/Common/HandlerOut.h127
-rw-r--r--3rdparty/lzma/CPP/7zip/Archive/Common/InStreamWithCRC.cpp29
-rw-r--r--3rdparty/lzma/CPP/7zip/Archive/Common/InStreamWithCRC.h46
-rw-r--r--3rdparty/lzma/CPP/7zip/Archive/Common/ItemNameUtils.cpp129
-rw-r--r--3rdparty/lzma/CPP/7zip/Archive/Common/ItemNameUtils.h33
-rw-r--r--3rdparty/lzma/CPP/7zip/Archive/Common/MultiStream.cpp56
-rw-r--r--3rdparty/lzma/CPP/7zip/Archive/Common/MultiStream.h51
-rw-r--r--3rdparty/lzma/CPP/7zip/Archive/Common/OutStreamWithCRC.cpp4
-rw-r--r--3rdparty/lzma/CPP/7zip/Archive/Common/OutStreamWithCRC.h14
-rw-r--r--3rdparty/lzma/CPP/7zip/Archive/Common/ParseProperties.h4
-rw-r--r--3rdparty/lzma/CPP/7zip/Archive/Common/StdAfx.h7
16 files changed, 806 insertions, 394 deletions
diff --git a/3rdparty/lzma/CPP/7zip/Archive/Common/CoderMixer2.cpp b/3rdparty/lzma/CPP/7zip/Archive/Common/CoderMixer2.cpp
index 41b5805c115..b6ddeb839c9 100644
--- a/3rdparty/lzma/CPP/7zip/Archive/Common/CoderMixer2.cpp
+++ b/3rdparty/lzma/CPP/7zip/Archive/Common/CoderMixer2.cpp
@@ -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)
@@ -60,6 +60,63 @@ static void BoolVector_Fill_False(CBoolVector &v, unsigned size)
p[i] = false;
}
+
+HRESULT CCoder::CheckDataAfterEnd(bool &dataAfterEnd_Error /* , bool &InternalPackSizeError */) const
+{
+ if (Coder)
+ {
+ if (PackSizePointers.IsEmpty() || !PackSizePointers[0])
+ return S_OK;
+ CMyComPtr<ICompressGetInStreamProcessedSize> getInStreamProcessedSize;
+ Coder.QueryInterface(IID_ICompressGetInStreamProcessedSize, (void **)&getInStreamProcessedSize);
+ // if (!getInStreamProcessedSize) return E_FAIL;
+ if (getInStreamProcessedSize)
+ {
+ UInt64 processed;
+ RINOK(getInStreamProcessedSize->GetInStreamProcessedSize(&processed))
+ if (processed != (UInt64)(Int64)-1)
+ {
+ const UInt64 size = PackSizes[0];
+ if (processed < size && Finish)
+ dataAfterEnd_Error = true;
+ if (processed > size)
+ {
+ // InternalPackSizeError = true;
+ // return S_FALSE;
+ }
+ }
+ }
+ }
+ else if (Coder2)
+ {
+ CMyComPtr<ICompressGetInStreamProcessedSize2> getInStreamProcessedSize2;
+ Coder2.QueryInterface(IID_ICompressGetInStreamProcessedSize2, (void **)&getInStreamProcessedSize2);
+ if (getInStreamProcessedSize2)
+ FOR_VECTOR (i, PackSizePointers)
+ {
+ if (!PackSizePointers[i])
+ continue;
+ UInt64 processed;
+ RINOK(getInStreamProcessedSize2->GetInStreamProcessedSize2(i, &processed))
+ if (processed != (UInt64)(Int64)-1)
+ {
+ const UInt64 size = PackSizes[i];
+ if (processed < size && Finish)
+ dataAfterEnd_Error = true;
+ else if (processed > size)
+ {
+ // InternalPackSizeError = true;
+ // return S_FALSE;
+ }
+ }
+ }
+ }
+
+ return S_OK;
+}
+
+
+
class CBondsChecks
{
CBoolVector _coderUsed;
@@ -80,7 +137,7 @@ bool CBondsChecks::CheckCoder(unsigned coderIndex)
return false;
_coderUsed[coderIndex] = true;
- UInt32 start = BindInfo->Coder_to_Stream[coderIndex];
+ const UInt32 start = BindInfo->Coder_to_Stream[coderIndex];
for (unsigned i = 0; i < coder.NumStreams; i++)
{
@@ -89,10 +146,10 @@ bool CBondsChecks::CheckCoder(unsigned coderIndex)
if (BindInfo->IsStream_in_PackStreams(ind))
continue;
- int bond = BindInfo->FindBond_for_PackStream(ind);
+ const int bond = BindInfo->FindBond_for_PackStream(ind);
if (bond < 0)
return false;
- if (!CheckCoder(BindInfo->Bonds[bond].UnpackIndex))
+ if (!CheckCoder(BindInfo->Bonds[(unsigned)bond].UnpackIndex))
return false;
}
@@ -151,8 +208,10 @@ bool CBindInfo::CalcMapsAndCheck()
}
-void CCoder::SetCoderInfo(const UInt64 *unpackSize, const UInt64 * const *packSizes)
+void CCoder::SetCoderInfo(const UInt64 *unpackSize, const UInt64 * const *packSizes, bool finish)
{
+ Finish = finish;
+
if (unpackSize)
{
UnpackSize = *unpackSize;
@@ -187,15 +246,15 @@ bool CMixer::Is_UnpackSize_Correct_for_Coder(UInt32 coderIndex)
if (coderIndex == _bi.UnpackCoder)
return true;
- int bond = _bi.FindBond_for_UnpackStream(coderIndex);
+ const int bond = _bi.FindBond_for_UnpackStream(coderIndex);
if (bond < 0)
throw 20150213;
/*
UInt32 coderIndex, coderStreamIndex;
- _bi.GetCoder_for_Stream(_bi.Bonds[bond].PackIndex, coderIndex, coderStreamIndex);
+ _bi.GetCoder_for_Stream(_bi.Bonds[(unsigned)bond].PackIndex, coderIndex, coderStreamIndex);
*/
- UInt32 nextCoder = _bi.Stream_to_Coder[_bi.Bonds[bond].PackIndex];
+ const UInt32 nextCoder = _bi.Stream_to_Coder[_bi.Bonds[(unsigned)bond].PackIndex];
if (!IsFilter_Vector[nextCoder])
return false;
@@ -208,11 +267,11 @@ bool CMixer::Is_PackSize_Correct_for_Stream(UInt32 streamIndex)
if (_bi.IsStream_in_PackStreams(streamIndex))
return true;
- int bond = _bi.FindBond_for_PackStream(streamIndex);
+ const int bond = _bi.FindBond_for_PackStream(streamIndex);
if (bond < 0)
throw 20150213;
- UInt32 nextCoder = _bi.Bonds[bond].UnpackIndex;
+ const UInt32 nextCoder = _bi.Bonds[(unsigned)bond].UnpackIndex;
if (!IsFilter_Vector[nextCoder])
return false;
@@ -222,8 +281,8 @@ bool CMixer::Is_PackSize_Correct_for_Stream(UInt32 streamIndex)
bool CMixer::Is_PackSize_Correct_for_Coder(UInt32 coderIndex)
{
- UInt32 startIndex = _bi.Coder_to_Stream[coderIndex];
- UInt32 numStreams = _bi.Coders[coderIndex].NumStreams;
+ const UInt32 startIndex = _bi.Coder_to_Stream[coderIndex];
+ const UInt32 numStreams = _bi.Coders[coderIndex].NumStreams;
for (UInt32 i = 0; i < numStreams; i++)
if (!Is_PackSize_Correct_for_Stream(startIndex + i))
return false;
@@ -234,19 +293,19 @@ bool CMixer::IsThere_ExternalCoder_in_PackTree(UInt32 coderIndex)
{
if (IsExternal_Vector[coderIndex])
return true;
- UInt32 startIndex = _bi.Coder_to_Stream[coderIndex];
- UInt32 numStreams = _bi.Coders[coderIndex].NumStreams;
+ const UInt32 startIndex = _bi.Coder_to_Stream[coderIndex];
+ const UInt32 numStreams = _bi.Coders[coderIndex].NumStreams;
for (UInt32 i = 0; i < numStreams; i++)
{
- UInt32 si = startIndex + i;
+ const UInt32 si = startIndex + i;
if (_bi.IsStream_in_PackStreams(si))
continue;
- int bond = _bi.FindBond_for_PackStream(si);
+ const int bond = _bi.FindBond_for_PackStream(si);
if (bond < 0)
throw 20150213;
- if (IsThere_ExternalCoder_in_PackTree(_bi.Bonds[bond].UnpackIndex))
+ if (IsThere_ExternalCoder_in_PackTree(_bi.Bonds[(unsigned)bond].UnpackIndex))
return true;
}
return false;
@@ -284,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);
}
}
@@ -301,7 +358,7 @@ CCoder &CMixerST::GetCoder(unsigned index)
return _coders[index];
}
-void CMixerST::ReInit() {}
+HRESULT CMixerST::ReInit2() { return S_OK; }
HRESULT CMixerST::GetInStream2(
ISequentialInStream * const *inStreams, /* const UInt64 * const *inSizes, */
@@ -323,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;
@@ -335,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;
}
}
@@ -351,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))
}
}
@@ -385,18 +442,18 @@ HRESULT CMixerST::GetInStream(
}
}
- int bond = FindBond_for_Stream(
+ const int bond = FindBond_for_Stream(
true, // forInputStream
inStreamIndex);
if (bond < 0)
return E_INVALIDARG;
RINOK(GetInStream2(inStreams, /* inSizes, */
- _bi.Bonds[bond].Get_OutIndex(EncodeMode), &seqInStream));
+ _bi.Bonds[(unsigned)bond].Get_OutIndex(EncodeMode), &seqInStream))
while (_binderStreams.Size() <= (unsigned)bond)
_binderStreams.AddNew();
- CStBinderStream &bs = _binderStreams[bond];
+ CStBinderStream &bs = _binderStreams[(unsigned)bond];
if (bs.StreamRef || bs.InStreamSpec)
return E_NOTIMPL;
@@ -439,13 +496,13 @@ HRESULT CMixerST::GetOutStream(
}
}
- int bond = FindBond_for_Stream(
+ const int bond = FindBond_for_Stream(
false, // forInputStream
outStreamIndex);
if (bond < 0)
return E_INVALIDARG;
- UInt32 inStreamIndex = _bi.Bonds[bond].Get_InIndex(EncodeMode);
+ const UInt32 inStreamIndex = _bi.Bonds[(unsigned)bond].Get_InIndex(EncodeMode);
UInt32 coderIndex = inStreamIndex;
UInt32 coderStreamIndex = 0;
@@ -464,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;
@@ -476,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;
}
}
@@ -493,15 +550,15 @@ 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))
}
*/
}
while (_binderStreams.Size() <= (unsigned)bond)
_binderStreams.AddNew();
- CStBinderStream &bs = _binderStreams[bond];
+ CStBinderStream &bs = _binderStreams[(unsigned)bond];
if (bs.StreamRef || bs.OutStreamSpec)
return E_NOTIMPL;
@@ -551,13 +608,13 @@ HRESULT CMixerST::FinishStream(UInt32 streamIndex)
return S_OK;
}
- int bond = FindBond_for_Stream(
+ const int bond = FindBond_for_Stream(
false, // forInputStream
streamIndex);
if (bond < 0)
return E_INVALIDARG;
- UInt32 inStreamIndex = _bi.Bonds[bond].Get_InIndex(EncodeMode);
+ const UInt32 inStreamIndex = _bi.Bonds[(unsigned)bond].Get_InIndex(EncodeMode);
UInt32 coderIndex = inStreamIndex;
UInt32 coderStreamIndex = 0;
@@ -580,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++)
@@ -595,7 +652,7 @@ void CMixerST::SelectMainCoder(bool useFirst)
unsigned ci = _bi.UnpackCoder;
int firstNonFilter = -1;
- int firstAllowed = ci;
+ unsigned firstAllowed = ci;
for (;;)
{
@@ -612,10 +669,10 @@ 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;
- int bond = _bi.FindBond_for_PackStream(st);
+ const int bond = _bi.FindBond_for_PackStream(st);
if (bond < 0)
throw 20150213;
@@ -623,15 +680,15 @@ void CMixerST::SelectMainCoder(bool useFirst)
break;
if (firstNonFilter == -1 && !IsFilter_Vector[ci])
- firstNonFilter = ci;
+ firstNonFilter = (int)ci;
- ci = _bi.Bonds[bond].UnpackIndex;
+ ci = _bi.Bonds[(unsigned)bond].UnpackIndex;
}
if (useFirst)
ci = firstAllowed;
else if (firstNonFilter >= 0)
- ci = firstNonFilter;
+ ci = (unsigned)firstNonFilter;
MainCoderIndex = ci;
}
@@ -640,35 +697,39 @@ void CMixerST::SelectMainCoder(bool useFirst)
HRESULT CMixerST::Code(
ISequentialInStream * const *inStreams,
ISequentialOutStream * const *outStreams,
- ICompressProgressInfo *progress)
+ ICompressProgressInfo *progress,
+ bool &dataAfterEnd_Error)
{
+ // InternalPackSizeError = false;
+ 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);
}
@@ -692,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))
+ }
}
}
@@ -742,7 +807,16 @@ HRESULT CMixerST::Code(
if (res == k_My_HRESULT_WritingWasCut)
res = S_OK;
- return res;
+
+ if (res != S_OK)
+ return res;
+
+ for (i = 0; i < _coders.Size(); i++)
+ {
+ RINOK(_coders[i].CheckDataAfterEnd(dataAfterEnd_Error /*, InternalPackSizeError */))
+ }
+
+ return S_OK;
}
@@ -762,7 +836,7 @@ HRESULT CMixerST::GetMainUnpackStream(
coder.QueryInterface(IID_ICompressSetOutStreamSize, (void **)&setOutStreamSize);
if (setOutStreamSize)
{
- RINOK(setOutStreamSize->SetOutStreamSize(coder.UnpackSizePointer));
+ RINOK(setOutStreamSize->SetOutStreamSize(coder.UnpackSizePointer))
}
}
@@ -847,7 +921,8 @@ 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;
}
@@ -869,10 +944,13 @@ CCoder &CMixerMT::GetCoder(unsigned index)
return _coders[index];
}
-void CMixerMT::ReInit()
+HRESULT CMixerMT::ReInit2()
{
FOR_VECTOR (i, _streamBinders)
- _streamBinders[i].ReInit();
+ {
+ RINOK(_streamBinders[i].Create_ReInit())
+ }
+ return S_OK;
}
void CMixerMT::SelectMainCoder(bool useFirst)
@@ -890,10 +968,10 @@ void CMixerMT::SelectMainCoder(bool useFirst)
UInt32 st = _bi.Coder_to_Stream[ci];
if (_bi.IsStream_in_PackStreams(st))
break;
- int bond = _bi.FindBond_for_PackStream(st);
+ const int bond = _bi.FindBond_for_PackStream(st);
if (bond < 0)
throw 20150213;
- ci = _bi.Bonds[bond].UnpackIndex;
+ ci = _bi.Bonds[(unsigned)bond].UnpackIndex;
}
MainCoderIndex = ci;
@@ -910,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++)
@@ -940,9 +1018,9 @@ HRESULT CMixerMT::Init(ISequentialInStream * const *inStreams, ISequentialOutStr
outCoderStreamIndex = EncodeMode ? coderStreamIndex : 0;
}
- _streamBinders[i].CreateStreams(
- &_coders[inCoderIndex].InStreams[inCoderStreamIndex],
- &_coders[outCoderIndex].OutStreams[outCoderStreamIndex]);
+ _streamBinders[i].CreateStreams2(
+ _coders[inCoderIndex].InStreams[inCoderStreamIndex],
+ _coders[outCoderIndex].OutStreams[outCoderStreamIndex]);
CMyComPtr<ICompressSetBufSize> inSetSize, outSetSize;
_coders[inCoderIndex].QueryInterface(IID_ICompressSetBufSize, (void **)&inSetSize);
@@ -988,29 +1066,46 @@ HRESULT CMixerMT::ReturnIfError(HRESULT code)
HRESULT CMixerMT::Code(
ISequentialInStream * const *inStreams,
ISequentialOutStream * const *outStreams,
- ICompressProgressInfo *progress)
+ ICompressProgressInfo *progress,
+ bool &dataAfterEnd_Error)
{
+ // InternalPackSizeError = false;
+ dataAfterEnd_Error = false;
+
Init(inStreams, outStreams);
unsigned i;
for (i = 0; i < _coders.Size(); i++)
if (i != MainCoderIndex)
{
- RINOK(_coders[i].Create());
+ const WRes wres = _coders[i].Create();
+ if (wres != 0)
+ return HRESULT_FROM_WIN32(wres);
}
for (i = 0; i < _coders.Size(); i++)
if (i != MainCoderIndex)
- _coders[i].Start();
+ {
+ const WRes wres = _coders[i].Start();
+ if (wres != 0)
+ return HRESULT_FROM_WIN32(wres);
+ }
_coders[MainCoderIndex].Code(progress);
+ WRes wres = 0;
for (i = 0; i < _coders.Size(); i++)
if (i != MainCoderIndex)
- _coders[i].WaitExecuteFinish();
+ {
+ WRes wres2 = _coders[i].WaitExecuteFinish();
+ if (wres == 0)
+ wres = wres2;
+ }
+ 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++)
{
@@ -1022,7 +1117,7 @@ HRESULT CMixerMT::Code(
return result;
}
- RINOK(ReturnIfError(S_FALSE));
+ RINOK(ReturnIfError(S_FALSE))
for (i = 0; i < _coders.Size(); i++)
{
@@ -1031,6 +1126,11 @@ HRESULT CMixerMT::Code(
return result;
}
+ for (i = 0; i < _coders.Size(); i++)
+ {
+ RINOK(_coders[i].CheckDataAfterEnd(dataAfterEnd_Error /* , InternalPackSizeError */))
+ }
+
return S_OK;
}
diff --git a/3rdparty/lzma/CPP/7zip/Archive/Common/CoderMixer2.h b/3rdparty/lzma/CPP/7zip/Archive/Common/CoderMixer2.h
index e63f2ff0efa..484a6089ad4 100644
--- a/3rdparty/lzma/CPP/7zip/Archive/Common/CoderMixer2.h
+++ b/3rdparty/lzma/CPP/7zip/Archive/Common/CoderMixer2.h
@@ -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; }
@@ -107,7 +97,7 @@ struct CBindInfo
{
FOR_VECTOR (i, Bonds)
if (Bonds[i].PackIndex == packStream)
- return i;
+ return (int)i;
return -1;
}
@@ -115,14 +105,14 @@ struct CBindInfo
{
FOR_VECTOR (i, Bonds)
if (Bonds[i].UnpackIndex == unpackStream)
- return i;
+ return (int)i;
return -1;
}
bool SetUnpackCoder()
{
bool isOk = false;
- FOR_VECTOR(i, Coders)
+ FOR_VECTOR (i, Coders)
{
if (FindBond_for_UnpackStream(i) < 0)
{
@@ -142,9 +132,9 @@ struct CBindInfo
int FindStream_in_PackStreams(UInt32 streamIndex) const
{
- FOR_VECTOR(i, PackStreams)
+ FOR_VECTOR (i, PackStreams)
if (PackStreams[i] == streamIndex)
- return i;
+ 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,9 +192,11 @@ public:
CRecordVector<UInt64> PackSizes;
CRecordVector<const UInt64 *> PackSizePointers;
- CCoder() {}
+ CCoder(): Finish(false) {}
+
+ void SetCoderInfo(const UInt64 *unpackSize, const UInt64 * const *packSizes, bool finish);
- void SetCoderInfo(const UInt64 *unpackSize, const UInt64 * const *packSizes);
+ HRESULT CheckDataAfterEnd(bool &dataAfterEnd_Error /* , bool &InternalPackSizeError */) const;
IUnknown *GetUnknown() const
{
@@ -239,11 +232,15 @@ protected:
public:
unsigned MainCoderIndex;
+ // bool InternalPackSizeError;
+
CMixer(bool encodeMode):
EncodeMode(encodeMode),
MainCoderIndex(0)
+ // , InternalPackSizeError(false)
{}
+ virtual ~CMixer() {}
/*
Sequence of calling:
@@ -272,12 +269,13 @@ public:
virtual void AddCoder(const CCreatedCoder &cod) = 0;
virtual CCoder &GetCoder(unsigned index) = 0;
virtual void SelectMainCoder(bool useFirst) = 0;
- virtual void ReInit() = 0;
- virtual void SetCoderInfo(unsigned coderIndex, const UInt64 *unpackSize, const UInt64 * const *packSizes) = 0;
+ virtual HRESULT ReInit2() = 0;
+ virtual void SetCoderInfo(unsigned coderIndex, const UInt64 *unpackSize, const UInt64 * const *packSizes, bool finish) = 0;
virtual HRESULT Code(
ISequentialInStream * const *inStreams,
ISequentialOutStream * const *outStreams,
- ICompressProgressInfo *progress) = 0;
+ ICompressProgressInfo *progress,
+ bool &dataAfterEnd_Error) = 0;
virtual UInt64 GetBondStreamSize(unsigned bondIndex) const = 0;
bool Is_UnpackSize_Correct_for_Coder(UInt32 coderIndex);
@@ -314,6 +312,9 @@ class CMixerST:
public CMixer,
public CMyUnknownImp
{
+ Z7_COM_UNKNOWN_IMP_0
+ Z7_CLASS_NO_COPY(CMixerST)
+
HRESULT GetInStream2(ISequentialInStream * const *inStreams, /* const UInt64 * const *inSizes, */
UInt32 outStreamIndex, ISequentialInStream **inStreamRes);
HRESULT GetInStream(ISequentialInStream * const *inStreams, /* const UInt64 * const *inSizes, */
@@ -329,22 +330,21 @@ public:
CObjectVector<CStBinderStream> _binderStreams;
- MY_UNKNOWN_IMP
-
CMixerST(bool encodeMode);
- ~CMixerST();
-
- virtual void AddCoder(const CCreatedCoder &cod);
- virtual CCoder &GetCoder(unsigned index);
- virtual void SelectMainCoder(bool useFirst);
- virtual void ReInit();
- virtual void SetCoderInfo(unsigned coderIndex, const UInt64 *unpackSize, const UInt64 * const *packSizes)
- { _coders[coderIndex].SetCoderInfo(unpackSize, packSizes); }
+ ~CMixerST() Z7_DESTRUCTOR_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);
- virtual UInt64 GetBondStreamSize(unsigned bondIndex) const;
+ ICompressProgressInfo *progress,
+ bool &dataAfterEnd_Error) Z7_override;
+ virtual UInt64 GetBondStreamSize(unsigned bondIndex) const Z7_override;
HRESULT GetMainUnpackStream(
ISequentialInStream * const *inStreams,
@@ -360,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;
@@ -385,7 +385,7 @@ public:
class CReleaser
{
- CLASS_NO_COPY(CReleaser)
+ Z7_CLASS_NO_COPY(CReleaser)
CCoderMT &_c;
public:
CReleaser(CCoderMT &c): _c(c) {}
@@ -393,7 +393,14 @@ public:
};
CCoderMT(): EncodeMode(false) {}
- ~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);
};
@@ -404,28 +411,31 @@ class CMixerMT:
public CMixer,
public CMyUnknownImp
{
+ 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() {}
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 void ReInit();
- virtual void SetCoderInfo(unsigned coderIndex, const UInt64 *unpackSize, const UInt64 * const *packSizes)
- { _coders[coderIndex].SetCoderInfo(unpackSize, packSizes); }
+ 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);
- virtual UInt64 GetBondStreamSize(unsigned bondIndex) const;
+ ICompressProgressInfo *progress,
+ bool &dataAfterEnd_Error) Z7_override;
+ virtual UInt64 GetBondStreamSize(unsigned bondIndex) const Z7_override;
CMixerMT(bool encodeMode): CMixer(encodeMode) {}
};
diff --git a/3rdparty/lzma/CPP/7zip/Archive/Common/DummyOutStream.cpp b/3rdparty/lzma/CPP/7zip/Archive/Common/DummyOutStream.cpp
index 7c4f54879de..f48c32f2fd7 100644
--- a/3rdparty/lzma/CPP/7zip/Archive/Common/DummyOutStream.cpp
+++ b/3rdparty/lzma/CPP/7zip/Archive/Common/DummyOutStream.cpp
@@ -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;
diff --git a/3rdparty/lzma/CPP/7zip/Archive/Common/DummyOutStream.h b/3rdparty/lzma/CPP/7zip/Archive/Common/DummyOutStream.h
index b5a51fc0755..f884e13c872 100644
--- a/3rdparty/lzma/CPP/7zip/Archive/Common/DummyOutStream.h
+++ b/3rdparty/lzma/CPP/7zip/Archive/Common/DummyOutStream.h
@@ -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; }
};
diff --git a/3rdparty/lzma/CPP/7zip/Archive/Common/HandlerOut.cpp b/3rdparty/lzma/CPP/7zip/Archive/Common/HandlerOut.cpp
index 30ca73bd023..17fed675b5d 100644
--- a/3rdparty/lzma/CPP/7zip/Archive/Common/HandlerOut.cpp
+++ b/3rdparty/lzma/CPP/7zip/Archive/Common/HandlerOut.cpp
@@ -2,54 +2,175 @@
#include "StdAfx.h"
-#ifndef _7ZIP_ST
-#include "../../../Windows/System.h"
-#endif
+#include "../../../Common/StringToInt.h"
#include "../Common/ParseProperties.h"
#include "HandlerOut.h"
-using namespace NWindows;
-
namespace NArchive {
-static void SetMethodProp32(COneMethodInfo &m, PROPID propID, UInt32 value)
+bool ParseSizeString(const wchar_t *s, const PROPVARIANT &prop, UInt64 percentsBase, UInt64 &res)
+{
+ if (*s == 0)
+ {
+ switch (prop.vt)
+ {
+ case VT_UI4: res = prop.ulVal; return true;
+ case VT_UI8: res = prop.uhVal.QuadPart; return true;
+ case VT_BSTR:
+ s = prop.bstrVal;
+ break;
+ default: return false;
+ }
+ }
+ else if (prop.vt != VT_EMPTY)
+ return false;
+
+ bool percentMode = false;
+ {
+ const wchar_t c = *s;
+ if (MyCharLower_Ascii(c) == 'p')
+ {
+ percentMode = true;
+ s++;
+ }
+ }
+
+ const wchar_t *end;
+ const UInt64 v = ConvertStringToUInt64(s, &end);
+ if (s == end)
+ return false;
+ const wchar_t c = *end;
+
+ if (percentMode)
+ {
+ if (c != 0)
+ return false;
+ res = Calc_From_Val_Percents(percentsBase, v);
+ return true;
+ }
+
+ if (c == 0)
+ {
+ res = v;
+ return true;
+ }
+ if (end[1] != 0)
+ return false;
+
+ if (c == '%')
+ {
+ res = Calc_From_Val_Percents(percentsBase, v);
+ return true;
+ }
+
+ unsigned numBits;
+ switch (MyCharLower_Ascii(c))
+ {
+ case 'b': numBits = 0; break;
+ case 'k': numBits = 10; break;
+ case 'm': numBits = 20; break;
+ case 'g': numBits = 30; break;
+ case 't': numBits = 40; break;
+ default: return false;
+ }
+ const UInt64 val2 = v << numBits;
+ if ((val2 >> numBits) != v)
+ return false;
+ res = val2;
+ return true;
+}
+
+bool CCommonMethodProps::SetCommonProperty(const UString &name, const PROPVARIANT &value, HRESULT &hres)
+{
+ hres = S_OK;
+
+ if (name.IsPrefixedBy_Ascii_NoCase("mt"))
+ {
+ #ifndef Z7_ST
+ _numThreads = _numProcessors;
+ _numThreads_WasForced = false;
+ hres = ParseMtProp2(name.Ptr(2), value, _numThreads, _numThreads_WasForced);
+ // "mt" means "_numThreads_WasForced = false" here
+ #endif
+ return true;
+ }
+
+ if (name.IsPrefixedBy_Ascii_NoCase("memuse"))
+ {
+ UInt64 v;
+ if (!ParseSizeString(name.Ptr(6), value, _memAvail, v))
+ hres = E_INVALIDARG;
+ _memUsage_Decompress = v;
+ _memUsage_Compress = v;
+ _memUsage_WasSet = true;
+ return true;
+ }
+
+ return false;
+}
+
+
+#ifndef Z7_EXTRACT_ONLY
+
+static void SetMethodProp32(CMethodProps &m, PROPID propID, UInt32 value)
{
if (m.FindProp(propID) < 0)
m.AddProp32(propID, value);
}
-void CMultiMethodProps::SetGlobalLevelAndThreads(COneMethodInfo &oneMethodInfo
- #ifndef _7ZIP_ST
- , UInt32 numThreads
- #endif
- )
+void CMultiMethodProps::SetGlobalLevelTo(COneMethodInfo &oneMethodInfo) const
{
UInt32 level = _level;
if (level != (UInt32)(Int32)-1)
SetMethodProp32(oneMethodInfo, NCoderPropID::kLevel, (UInt32)level);
-
- #ifndef _7ZIP_ST
+}
+
+#ifndef Z7_ST
+
+static void SetMethodProp32_Replace(CMethodProps &m, PROPID propID, UInt32 value)
+{
+ const int i = m.FindProp(propID);
+ if (i >= 0)
+ {
+ NWindows::NCOM::CPropVariant &val = m.Props[(unsigned)i].Value;
+ val = (UInt32)value;
+ return;
+ }
+ m.AddProp32(propID, value);
+}
+
+void CMultiMethodProps::SetMethodThreadsTo_IfNotFinded(CMethodProps &oneMethodInfo, UInt32 numThreads)
+{
SetMethodProp32(oneMethodInfo, NCoderPropID::kNumThreads, numThreads);
- #endif
}
-void CMultiMethodProps::Init()
+void CMultiMethodProps::SetMethodThreadsTo_Replace(CMethodProps &oneMethodInfo, UInt32 numThreads)
+{
+ SetMethodProp32_Replace(oneMethodInfo, NCoderPropID::kNumThreads, numThreads);
+}
+
+#endif // Z7_ST
+
+
+void CMultiMethodProps::InitMulti()
{
- #ifndef _7ZIP_ST
- _numProcessors = _numThreads = NSystem::GetNumberOfProcessors();
- #endif
-
_level = (UInt32)(Int32)-1;
_analysisLevel = -1;
-
- _autoFilter = true;
_crcSize = 4;
- _filterMethod.Clear();
+ _autoFilter = true;
+}
+
+void CMultiMethodProps::Init()
+{
+ InitCommon();
+ InitMulti();
_methods.Clear();
+ _filterMethod.Clear();
}
+
HRESULT CMultiMethodProps::SetProperty(const wchar_t *nameSpec, const PROPVARIANT &value)
{
UString name = nameSpec;
@@ -68,34 +189,32 @@ 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;
}
- if (name.IsEqualTo("crc"))
+ if (name.IsPrefixedBy_Ascii_NoCase("crc"))
{
name.Delete(0, 3);
_crcSize = 4;
return ParsePropToUInt32(name, value, _crcSize);
}
+
+ {
+ HRESULT hres;
+ if (SetCommonProperty(name, value, hres))
+ return hres;
+ }
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.IsPrefixedBy_Ascii_NoCase("mt"))
- {
- #ifndef _7ZIP_ST
- RINOK(ParseMtProp(name.Ptr(2), value, _numProcessors, _numThreads));
- #endif
-
- return S_OK;
- }
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)
@@ -105,52 +224,87 @@ HRESULT CMultiMethodProps::SetProperty(const wchar_t *nameSpec, const PROPVARIAN
number = 0;
}
if (number > 64)
- return E_FAIL;
- for (int j = _methods.Size(); j <= (int)number; j++)
- _methods.Add(COneMethodInfo());
+ return E_INVALIDARG;
+ for (unsigned j = _methods.Size(); j <= number; j++)
+ _methods.AddNew();
return _methods[number].ParseMethodFromPROPVARIANT(realName, value);
}
+
+
void CSingleMethodProps::Init()
{
+ InitCommon();
+ InitSingle();
Clear();
- _level = (UInt32)(Int32)-1;
-
- #ifndef _7ZIP_ST
- _numProcessors = _numThreads = NWindows::NSystem::GetNumberOfProcessors();
- AddProp_NumThreads(_numThreads);
- #endif
}
+
+HRESULT CSingleMethodProps::SetProperty(const wchar_t *name2, const PROPVARIANT &value)
+{
+ // processed = false;
+ UString name = name2;
+ name.MakeLower_Ascii();
+ if (name.IsEmpty())
+ return E_INVALIDARG;
+ if (name.IsPrefixedBy_Ascii_NoCase("x"))
+ {
+ UInt32 a = 9;
+ RINOK(ParsePropToUInt32(name.Ptr(1), value, a))
+ _level = a;
+ AddProp_Level(a);
+ // processed = true;
+ return S_OK;
+ }
+ {
+ HRESULT hres;
+ if (SetCommonProperty(name, value, hres))
+ {
+ // processed = true;
+ return S_OK;
+ }
+ }
+ RINOK(ParseMethodFromPROPVARIANT(name, value))
+ return S_OK;
+}
+
+
HRESULT CSingleMethodProps::SetProperties(const wchar_t * const *names, const PROPVARIANT *values, UInt32 numProps)
{
Init();
+
for (UInt32 i = 0; i < numProps; i++)
{
- UString name = names[i];
- name.MakeLower_Ascii();
- if (name.IsEmpty())
- return E_INVALIDARG;
- const PROPVARIANT &value = values[i];
- if (name[0] == L'x')
- {
- UInt32 a = 9;
- RINOK(ParsePropToUInt32(name.Ptr(1), value, a));
- _level = a;
- AddProp_Level(a);
- }
- else if (name.IsPrefixedBy_Ascii_NoCase("mt"))
- {
- #ifndef _7ZIP_ST
- RINOK(ParseMtProp(name.Ptr(2), value, _numProcessors, _numThreads));
- AddProp_NumThreads(_numThreads);
- #endif
- }
- else
- {
- RINOK(ParseMethodFromPROPVARIANT(names[i], value));
- }
+ RINOK(SetProperty(names[i], values[i]))
+ }
+
+ return S_OK;
+}
+
+#endif
+
+
+static HRESULT PROPVARIANT_to_BoolPair(const PROPVARIANT &prop, CBoolPair &dest)
+{
+ RINOK(PROPVARIANT_to_bool(prop, dest.Val))
+ dest.Def = true;
+ return S_OK;
+}
+
+HRESULT CHandlerTimeOptions::Parse(const UString &name, const PROPVARIANT &prop, bool &processed)
+{
+ processed = true;
+ if (name.IsEqualTo_Ascii_NoCase("tm")) { return PROPVARIANT_to_BoolPair(prop, Write_MTime); }
+ if (name.IsEqualTo_Ascii_NoCase("ta")) { return PROPVARIANT_to_BoolPair(prop, Write_ATime); }
+ if (name.IsEqualTo_Ascii_NoCase("tc")) { return PROPVARIANT_to_BoolPair(prop, Write_CTime); }
+ if (name.IsPrefixedBy_Ascii_NoCase("tp"))
+ {
+ UInt32 v = 0;
+ RINOK(ParsePropToUInt32(name.Ptr(2), prop, v))
+ Prec = v;
+ return S_OK;
}
+ processed = false;
return S_OK;
}
diff --git a/3rdparty/lzma/CPP/7zip/Archive/Common/HandlerOut.h b/3rdparty/lzma/CPP/7zip/Archive/Common/HandlerOut.h
index 5a18d9802b3..cfba46e245b 100644
--- a/3rdparty/lzma/CPP/7zip/Archive/Common/HandlerOut.h
+++ b/3rdparty/lzma/CPP/7zip/Archive/Common/HandlerOut.h
@@ -1,32 +1,90 @@
// 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"
#include "../../Common/MethodProps.h"
namespace NArchive {
-class CMultiMethodProps
+bool ParseSizeString(const wchar_t *name, const PROPVARIANT &prop, UInt64 percentsBase, UInt64 &res);
+
+class CCommonMethodProps
{
- UInt32 _level;
- int _analysisLevel;
+protected:
+ void InitCommon()
+ {
+ // _Write_MTime = true;
+ #ifndef Z7_ST
+ _numProcessors = _numThreads = NWindows::NSystem::GetNumberOfProcessors();
+ _numThreads_WasForced = false;
+ #endif
+
+ UInt64 memAvail = (UInt64)(sizeof(size_t)) << 28;
+ _memAvail = memAvail;
+ _memUsage_Compress = memAvail;
+ _memUsage_Decompress = memAvail;
+ _memUsage_WasSet = NWindows::NSystem::GetRamSize(memAvail);
+ if (_memUsage_WasSet)
+ {
+ _memAvail = memAvail;
+ unsigned bits = sizeof(size_t) * 8;
+ if (bits == 32)
+ {
+ const UInt32 limit2 = (UInt32)7 << 28;
+ if (memAvail > limit2)
+ memAvail = limit2;
+ }
+ // 80% - is auto usage limit in handlers
+ // _memUsage_Compress = memAvail * 4 / 5;
+ // _memUsage_Compress = Calc_From_Val_Percents(memAvail, 80);
+ _memUsage_Compress = Calc_From_Val_Percents_Less100(memAvail, 80);
+ _memUsage_Decompress = memAvail / 32 * 17;
+ }
+ }
+
public:
- #ifndef _7ZIP_ST
+ #ifndef Z7_ST
UInt32 _numThreads;
UInt32 _numProcessors;
+ bool _numThreads_WasForced;
#endif
+ bool _memUsage_WasSet;
+ UInt64 _memUsage_Compress;
+ UInt64 _memUsage_Decompress;
+ UInt64 _memAvail;
+
+ bool SetCommonProperty(const UString &name, const PROPVARIANT &value, HRESULT &hres);
+
+ CCommonMethodProps() { InitCommon(); }
+};
+
+
+#ifndef Z7_EXTRACT_ONLY
+
+class CMultiMethodProps: public CCommonMethodProps
+{
+ UInt32 _level;
+ int _analysisLevel;
+
+ void InitMulti();
+public:
UInt32 _crcSize;
CObjectVector<COneMethodInfo> _methods;
COneMethodInfo _filterMethod;
bool _autoFilter;
- void SetGlobalLevelAndThreads(COneMethodInfo &oneMethodInfo
- #ifndef _7ZIP_ST
- , UInt32 numThreads
- #endif
- );
+
+ void SetGlobalLevelTo(COneMethodInfo &oneMethodInfo) const;
+
+ #ifndef Z7_ST
+ static void SetMethodThreadsTo_IfNotFinded(CMethodProps &props, UInt32 numThreads);
+ static void SetMethodThreadsTo_Replace(CMethodProps &props, UInt32 numThreads);
+ #endif
+
unsigned GetNumEmptyMethods() const
{
@@ -41,27 +99,56 @@ public:
int GetAnalysisLevel() const { return _analysisLevel; }
void Init();
+ CMultiMethodProps() { InitMulti(); }
- CMultiMethodProps() { Init(); }
HRESULT SetProperty(const wchar_t *name, const PROPVARIANT &value);
};
-class CSingleMethodProps: public COneMethodInfo
+
+class CSingleMethodProps: public COneMethodInfo, public CCommonMethodProps
{
UInt32 _level;
-
-public:
- #ifndef _7ZIP_ST
- UInt32 _numThreads;
- UInt32 _numProcessors;
- #endif
+ void InitSingle()
+ {
+ _level = (UInt32)(Int32)-1;
+ }
+
+public:
void Init();
- CSingleMethodProps() { Init(); }
+ CSingleMethodProps() { InitSingle(); }
+
int GetLevel() const { return _level == (UInt32)(Int32)-1 ? 5 : (int)_level; }
+ HRESULT SetProperty(const wchar_t *name, const PROPVARIANT &values);
HRESULT SetProperties(const wchar_t * const *names, const PROPVARIANT *values, UInt32 numProps);
};
+#endif
+
+struct CHandlerTimeOptions
+{
+ CBoolPair Write_MTime;
+ CBoolPair Write_ATime;
+ CBoolPair Write_CTime;
+ UInt32 Prec;
+
+ void Init()
+ {
+ Write_MTime.Init();
+ Write_MTime.Val = true;
+ Write_ATime.Init();
+ Write_CTime.Init();
+ Prec = (UInt32)(Int32)-1;
+ }
+
+ CHandlerTimeOptions()
+ {
+ Init();
+ }
+
+ HRESULT Parse(const UString &name, const PROPVARIANT &prop, bool &processed);
+};
+
}
#endif
diff --git a/3rdparty/lzma/CPP/7zip/Archive/Common/InStreamWithCRC.cpp b/3rdparty/lzma/CPP/7zip/Archive/Common/InStreamWithCRC.cpp
index a2d68832838..735d5d1eb0e 100644
--- a/3rdparty/lzma/CPP/7zip/Archive/Common/InStreamWithCRC.cpp
+++ b/3rdparty/lzma/CPP/7zip/Archive/Common/InStreamWithCRC.cpp
@@ -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;
diff --git a/3rdparty/lzma/CPP/7zip/Archive/Common/InStreamWithCRC.h b/3rdparty/lzma/CPP/7zip/Archive/Common/InStreamWithCRC.h
index 31b761e4566..2a91d76742a 100644
--- a/3rdparty/lzma/CPP/7zip/Archive/Common/InStreamWithCRC.h
+++ b/3rdparty/lzma/CPP/7zip/Archive/Common/InStreamWithCRC.h
@@ -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;
diff --git a/3rdparty/lzma/CPP/7zip/Archive/Common/ItemNameUtils.cpp b/3rdparty/lzma/CPP/7zip/Archive/Common/ItemNameUtils.cpp
index 7cd3037be50..8caf1d141b1 100644
--- a/3rdparty/lzma/CPP/7zip/Archive/Common/ItemNameUtils.cpp
+++ b/3rdparty/lzma/CPP/7zip/Archive/Common/ItemNameUtils.cpp
@@ -7,58 +7,101 @@
namespace NArchive {
namespace NItemName {
-static const wchar_t kOSDirDelimiter = WCHAR_PATH_SEPARATOR;
-static const wchar_t kDirDelimiter = L'/';
+static const wchar_t kOsPathSepar = WCHAR_PATH_SEPARATOR;
-void ReplaceToOsPathSeparator(wchar_t *s)
-{
- #ifdef _WIN32
- for (;;)
+#if WCHAR_PATH_SEPARATOR != L'/'
+static const wchar_t kUnixPathSepar = L'/';
+#endif
+
+void ReplaceSlashes_OsToUnix
+#if WCHAR_PATH_SEPARATOR != L'/'
+ (UString &name)
{
- wchar_t c = *s;
- if (c == 0)
- break;
- if (c == kDirDelimiter)
- *s = kOSDirDelimiter;
- s++;
+ name.Replace(kOsPathSepar, kUnixPathSepar);
}
- #endif
-}
+#else
+ (UString &) {}
+#endif
-UString MakeLegalName(const UString &name)
-{
- UString zipName = name;
- zipName.Replace(kOSDirDelimiter, kDirDelimiter);
- return zipName;
-}
-UString GetOSName(const UString &name)
+UString GetOsPath(const UString &name)
{
- UString newName = name;
- newName.Replace(kDirDelimiter, kOSDirDelimiter);
- return newName;
+ #if WCHAR_PATH_SEPARATOR != L'/'
+ UString newName = name;
+ newName.Replace(kUnixPathSepar, kOsPathSepar);
+ return newName;
+ #else
+ return name;
+ #endif
}
-UString GetOSName2(const UString &name)
+
+UString GetOsPath_Remove_TailSlash(const UString &name)
{
if (name.IsEmpty())
return UString();
- UString newName = GetOSName(name);
- if (newName.Back() == kOSDirDelimiter)
+ UString newName = GetOsPath(name);
+ if (newName.Back() == kOsPathSepar)
newName.DeleteBack();
return newName;
}
-void ConvertToOSName2(UString &name)
+
+void ReplaceToOsSlashes_Remove_TailSlash(UString &name, bool
+ #if WCHAR_PATH_SEPARATOR != L'/'
+ useBackslashReplacement
+ #endif
+ )
{
- if (!name.IsEmpty())
+ if (name.IsEmpty())
+ return;
+
+ #if WCHAR_PATH_SEPARATOR != L'/'
{
- name.Replace(kDirDelimiter, kOSDirDelimiter);
- if (name.Back() == kOSDirDelimiter)
- name.DeleteBack();
+ // name.Replace(kUnixPathSepar, kOsPathSepar);
+ const unsigned len = name.Len();
+ for (unsigned i = 0; i < len; i++)
+ {
+ wchar_t c = name[i];
+ if (c == L'/')
+ c = WCHAR_PATH_SEPARATOR;
+ else if (useBackslashReplacement && c == L'\\')
+ c = WCHAR_IN_FILE_NAME_BACKSLASH_REPLACEMENT; // WSL scheme
+ else
+ continue;
+ name.ReplaceOneCharAtPos(i, c);
+ }
+ }
+ #endif
+
+ if (name.Back() == kOsPathSepar)
+ name.DeleteBack();
+}
+
+
+void NormalizeSlashes_in_FileName_for_OsPath(wchar_t *name, unsigned len)
+{
+ for (unsigned i = 0; i < len; i++)
+ {
+ wchar_t c = name[i];
+ if (c == L'/')
+ c = L'_';
+ #if WCHAR_PATH_SEPARATOR != L'/'
+ else if (c == L'\\')
+ c = WCHAR_IN_FILE_NAME_BACKSLASH_REPLACEMENT; // WSL scheme
+ #endif
+ else
+ continue;
+ name[i] = c;
}
}
+void NormalizeSlashes_in_FileName_for_OsPath(UString &name)
+{
+ NormalizeSlashes_in_FileName_for_OsPath(name.GetBuf(), name.Len());
+}
+
+
bool HasTailSlash(const AString &name, UINT
#if defined(_WIN32) && !defined(UNDER_CE)
codePage
@@ -67,20 +110,24 @@ bool HasTailSlash(const AString &name, UINT
{
if (name.IsEmpty())
return false;
- LPCSTR prev =
- #if defined(_WIN32) && !defined(UNDER_CE)
- CharPrevExA((WORD)codePage, name, &name[name.Len()], 0);
- #else
- (LPCSTR)(name) + (name.Len() - 1);
- #endif
- return (*prev == '/');
+ char c;
+ #if defined(_WIN32) && !defined(UNDER_CE)
+ if (codePage != CP_UTF8)
+ c = *CharPrevExA((WORD)codePage, name, name.Ptr(name.Len()), 0);
+ else
+ #endif
+ {
+ c = name.Back();
+ }
+ return (c == '/');
}
+
#ifndef _WIN32
-UString WinNameToOSName(const UString &name)
+UString WinPathToOsPath(const UString &name)
{
UString newName = name;
- newName.Replace(L'\\', kOSDirDelimiter);
+ newName.Replace(L'\\', WCHAR_PATH_SEPARATOR);
return newName;
}
#endif
diff --git a/3rdparty/lzma/CPP/7zip/Archive/Common/ItemNameUtils.h b/3rdparty/lzma/CPP/7zip/Archive/Common/ItemNameUtils.h
index d0dc76a4109..8ab9b610a0f 100644
--- a/3rdparty/lzma/CPP/7zip/Archive/Common/ItemNameUtils.h
+++ b/3rdparty/lzma/CPP/7zip/Archive/Common/ItemNameUtils.h
@@ -1,26 +1,29 @@
// 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"
namespace NArchive {
namespace NItemName {
- void ReplaceToOsPathSeparator(wchar_t *s);
-
- UString MakeLegalName(const UString &name);
- UString GetOSName(const UString &name);
- UString GetOSName2(const UString &name);
- void ConvertToOSName2(UString &name);
- bool HasTailSlash(const AString &name, UINT codePage);
-
- #ifdef _WIN32
- inline UString WinNameToOSName(const UString &name) { return name; }
- #else
- UString WinNameToOSName(const UString &name);
- #endif
+void ReplaceSlashes_OsToUnix(UString &name);
+
+UString GetOsPath(const UString &name);
+UString GetOsPath_Remove_TailSlash(const UString &name);
+
+void ReplaceToOsSlashes_Remove_TailSlash(UString &name, bool useBackslashReplacement = false);
+void NormalizeSlashes_in_FileName_for_OsPath(wchar_t *s, unsigned len);
+void NormalizeSlashes_in_FileName_for_OsPath(UString &name);
+
+bool HasTailSlash(const AString &name, UINT codePage);
+
+#ifdef _WIN32
+ inline UString WinPathToOsPath(const UString &name) { return name; }
+#else
+ UString WinPathToOsPath(const UString &name);
+#endif
}}
diff --git a/3rdparty/lzma/CPP/7zip/Archive/Common/MultiStream.cpp b/3rdparty/lzma/CPP/7zip/Archive/Common/MultiStream.cpp
index 1de74afe43e..5d357af7113 100644
--- a/3rdparty/lzma/CPP/7zip/Archive/Common/MultiStream.cpp
+++ b/3rdparty/lzma/CPP/7zip/Archive/Common/MultiStream.cpp
@@ -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(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)
{
@@ -60,9 +59,9 @@ STDMETHODIMP CMultiStream::Seek(Int64 offset, UInt32 seekOrigin, UInt64 *newPosi
}
if (offset < 0)
return HRESULT_WIN32_ERROR_NEGATIVE_SEEK;
- _pos = offset;
+ _pos = (UInt64)offset;
if (newPosition)
- *newPosition = offset;
+ *newPosition = (UInt64)offset;
return S_OK;
}
@@ -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;
}
*/
diff --git a/3rdparty/lzma/CPP/7zip/Archive/Common/MultiStream.h b/3rdparty/lzma/CPP/7zip/Archive/Common/MultiStream.h
index c10cd455729..e3096f58d93 100644
--- a/3rdparty/lzma/CPP/7zip/Archive/Common/MultiStream.h
+++ b/3rdparty/lzma/CPP/7zip/Archive/Common/MultiStream.h
@@ -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);
};
*/
diff --git a/3rdparty/lzma/CPP/7zip/Archive/Common/OutStreamWithCRC.cpp b/3rdparty/lzma/CPP/7zip/Archive/Common/OutStreamWithCRC.cpp
index f955c22547b..7dcd44ac13c 100644
--- a/3rdparty/lzma/CPP/7zip/Archive/Common/OutStreamWithCRC.cpp
+++ b/3rdparty/lzma/CPP/7zip/Archive/Common/OutStreamWithCRC.cpp
@@ -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;
}
diff --git a/3rdparty/lzma/CPP/7zip/Archive/Common/OutStreamWithCRC.h b/3rdparty/lzma/CPP/7zip/Archive/Common/OutStreamWithCRC.h
index 09b899bbd74..845146a1b9d 100644
--- a/3rdparty/lzma/CPP/7zip/Archive/Common/OutStreamWithCRC.h
+++ b/3rdparty/lzma/CPP/7zip/Archive/Common/OutStreamWithCRC.h
@@ -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)
diff --git a/3rdparty/lzma/CPP/7zip/Archive/Common/ParseProperties.h b/3rdparty/lzma/CPP/7zip/Archive/Common/ParseProperties.h
index 1038a8c020c..4ec2e48ed9d 100644
--- a/3rdparty/lzma/CPP/7zip/Archive/Common/ParseProperties.h
+++ b/3rdparty/lzma/CPP/7zip/Archive/Common/ParseProperties.h
@@ -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
diff --git a/3rdparty/lzma/CPP/7zip/Archive/Common/StdAfx.h b/3rdparty/lzma/CPP/7zip/Archive/Common/StdAfx.h
index 2854ff3e935..035267ccd02 100644
--- a/3rdparty/lzma/CPP/7zip/Archive/Common/StdAfx.h
+++ b/3rdparty/lzma/CPP/7zip/Archive/Common/StdAfx.h
@@ -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