chore: initial commit (extracted from Launchers monorepo)

Plugin: ns7zip v2.0.0
Architectures: x86-ansi, x86-unicode, amd64-unicode
License: LGPL-2.1-or-later
This commit is contained in:
Simone
2026-04-29 14:07:51 +02:00
commit d074cc7c07
3848 changed files with 1076682 additions and 0 deletions
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,447 @@
// CoderMixer2.h
#ifndef ZIP7_INC_CODER_MIXER2_H
#define ZIP7_INC_CODER_MIXER2_H
#include "../../../Common/MyCom.h"
#include "../../../Common/MyVector.h"
#include "../../ICoder.h"
#include "../../Common/CreateCoder.h"
#ifdef Z7_ST
#define USE_MIXER_ST
#else
#define USE_MIXER_MT
#ifndef Z7_SFX
#define USE_MIXER_ST
#endif
#endif
#ifdef USE_MIXER_MT
#include "../../Common/StreamBinder.h"
#include "../../Common/VirtThread.h"
#endif
#ifdef USE_MIXER_ST
Z7_CLASS_IMP_COM_1(
CSequentialInStreamCalcSize
, ISequentialInStream
)
bool _wasFinished;
CMyComPtr<ISequentialInStream> _stream;
UInt64 _size;
public:
void SetStream(ISequentialInStream *stream) { _stream = stream; }
void Init()
{
_size = 0;
_wasFinished = false;
}
void ReleaseStream() { _stream.Release(); }
UInt64 GetSize() const { return _size; }
bool WasFinished() const { return _wasFinished; }
};
Z7_CLASS_IMP_COM_2(
COutStreamCalcSize
, ISequentialOutStream
, IOutStreamFinish
)
CMyComPtr<ISequentialOutStream> _stream;
UInt64 _size;
public:
void SetStream(ISequentialOutStream *stream) { _stream = stream; }
void ReleaseStream() { _stream.Release(); }
void Init() { _size = 0; }
UInt64 GetSize() const { return _size; }
};
#endif
namespace NCoderMixer2 {
struct CBond
{
UInt32 PackIndex;
UInt32 UnpackIndex;
UInt32 Get_InIndex(bool encodeMode) const { return encodeMode ? UnpackIndex : PackIndex; }
UInt32 Get_OutIndex(bool encodeMode) const { return encodeMode ? PackIndex : UnpackIndex; }
};
struct CCoderStreamsInfo
{
UInt32 NumStreams;
};
struct CBindInfo
{
CRecordVector<CCoderStreamsInfo> Coders;
CRecordVector<CBond> Bonds;
CRecordVector<UInt32> PackStreams;
unsigned UnpackCoder;
unsigned GetNum_Bonds_and_PackStreams() const { return Bonds.Size() + PackStreams.Size(); }
int FindBond_for_PackStream(UInt32 packStream) const
{
FOR_VECTOR (i, Bonds)
if (Bonds[i].PackIndex == packStream)
return (int)i;
return -1;
}
int FindBond_for_UnpackStream(UInt32 unpackStream) const
{
FOR_VECTOR (i, Bonds)
if (Bonds[i].UnpackIndex == unpackStream)
return (int)i;
return -1;
}
bool SetUnpackCoder()
{
bool isOk = false;
FOR_VECTOR (i, Coders)
{
if (FindBond_for_UnpackStream(i) < 0)
{
if (isOk)
return false;
UnpackCoder = i;
isOk = true;
}
}
return isOk;
}
bool IsStream_in_PackStreams(UInt32 streamIndex) const
{
return FindStream_in_PackStreams(streamIndex) >= 0;
}
int FindStream_in_PackStreams(UInt32 streamIndex) const
{
FOR_VECTOR (i, PackStreams)
if (PackStreams[i] == streamIndex)
return (int)i;
return -1;
}
// that function is used before Maps is calculated
UInt32 GetStream_for_Coder(UInt32 coderIndex) const
{
UInt32 streamIndex = 0;
for (UInt32 i = 0; i < coderIndex; i++)
streamIndex += Coders[i].NumStreams;
return streamIndex;
}
// ---------- Maps Section ----------
CRecordVector<UInt32> Coder_to_Stream;
CRecordVector<UInt32> Stream_to_Coder;
void ClearMaps();
bool CalcMapsAndCheck();
// ---------- End of Maps Section ----------
void Clear()
{
Coders.Clear();
Bonds.Clear();
PackStreams.Clear();
ClearMaps();
}
void GetCoder_for_Stream(UInt32 streamIndex, UInt32 &coderIndex, UInt32 &coderStreamIndex) const
{
coderIndex = Stream_to_Coder[streamIndex];
coderStreamIndex = streamIndex - Coder_to_Stream[coderIndex];
}
};
class CCoder
{
Z7_CLASS_NO_COPY(CCoder)
public:
CMyComPtr<ICompressCoder> Coder;
CMyComPtr<ICompressCoder2> Coder2;
UInt32 NumStreams;
bool Finish;
UInt64 UnpackSize;
const UInt64 *UnpackSizePointer;
CRecordVector<UInt64> PackSizes;
CRecordVector<const UInt64 *> PackSizePointers;
CCoder(): Finish(false) {}
void SetCoderInfo(const UInt64 *unpackSize, const UInt64 * const *packSizes, bool finish);
HRESULT CheckDataAfterEnd(bool &dataAfterEnd_Error /* , bool &InternalPackSizeError */) const;
IUnknown *GetUnknown() const
{
return Coder ? (IUnknown *)Coder : (IUnknown *)Coder2;
}
HRESULT QueryInterface(REFGUID iid, void** pp) const
{
return GetUnknown()->QueryInterface(iid, pp);
}
};
class CMixer
{
bool Is_PackSize_Correct_for_Stream(UInt32 streamIndex);
protected:
CBindInfo _bi;
int FindBond_for_Stream(bool forInputStream, UInt32 streamIndex) const
{
if (EncodeMode == forInputStream)
return _bi.FindBond_for_UnpackStream(streamIndex);
else
return _bi.FindBond_for_PackStream(streamIndex);
}
CBoolVector IsFilter_Vector;
CBoolVector IsExternal_Vector;
bool EncodeMode;
public:
unsigned MainCoderIndex;
// bool InternalPackSizeError;
CMixer(bool encodeMode):
EncodeMode(encodeMode),
MainCoderIndex(0)
// , InternalPackSizeError(false)
{}
virtual ~CMixer() {}
/*
Sequence of calling:
SetBindInfo();
for each coder
AddCoder();
SelectMainCoder();
for each file
{
ReInit()
for each coder
SetCoderInfo();
Code();
}
*/
virtual HRESULT SetBindInfo(const CBindInfo &bindInfo)
{
_bi = bindInfo;
IsFilter_Vector.Clear();
MainCoderIndex = 0;
return S_OK;
}
virtual void AddCoder(const CCreatedCoder &cod) = 0;
virtual CCoder &GetCoder(unsigned index) = 0;
virtual void SelectMainCoder(bool useFirst) = 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,
bool &dataAfterEnd_Error) = 0;
virtual UInt64 GetBondStreamSize(unsigned bondIndex) const = 0;
bool Is_UnpackSize_Correct_for_Coder(UInt32 coderIndex);
bool Is_PackSize_Correct_for_Coder(UInt32 coderIndex);
bool IsThere_ExternalCoder_in_PackTree(UInt32 coderIndex);
};
#ifdef USE_MIXER_ST
struct CCoderST: public CCoder
{
bool CanRead;
bool CanWrite;
CCoderST(): CanRead(false), CanWrite(false) {}
};
struct CStBinderStream
{
CSequentialInStreamCalcSize *InStreamSpec;
COutStreamCalcSize *OutStreamSpec;
CMyComPtr<IUnknown> StreamRef;
CStBinderStream(): InStreamSpec(NULL), OutStreamSpec(NULL) {}
};
class CMixerST:
public IUnknown,
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, */
UInt32 inStreamIndex, ISequentialInStream **inStreamRes);
HRESULT GetOutStream(ISequentialOutStream * const *outStreams, /* const UInt64 * const *outSizes, */
UInt32 outStreamIndex, ISequentialOutStream **outStreamRes);
HRESULT FinishStream(UInt32 streamIndex);
HRESULT FinishCoder(UInt32 coderIndex);
public:
CObjectVector<CCoderST> _coders;
CObjectVector<CStBinderStream> _binderStreams;
CMixerST(bool encodeMode);
~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,
bool &dataAfterEnd_Error) Z7_override;
virtual UInt64 GetBondStreamSize(unsigned bondIndex) const Z7_override;
HRESULT GetMainUnpackStream(
ISequentialInStream * const *inStreams,
ISequentialInStream **inStreamRes);
};
#endif
#ifdef USE_MIXER_MT
class CCoderMT: public CCoder, public CVirtThread
{
Z7_CLASS_NO_COPY(CCoderMT)
CRecordVector<ISequentialInStream*> InStreamPointers;
CRecordVector<ISequentialOutStream*> OutStreamPointers;
private:
virtual void Execute() Z7_override;
public:
bool EncodeMode;
HRESULT Result;
CObjectVector< CMyComPtr<ISequentialInStream> > InStreams;
CObjectVector< CMyComPtr<ISequentialOutStream> > OutStreams;
void Release()
{
InStreamPointers.Clear();
OutStreamPointers.Clear();
unsigned i;
for (i = 0; i < InStreams.Size(); i++)
InStreams[i].Release();
for (i = 0; i < OutStreams.Size(); i++)
OutStreams[i].Release();
}
class CReleaser
{
Z7_CLASS_NO_COPY(CReleaser)
CCoderMT &_c;
public:
CReleaser(CCoderMT &c): _c(c) {}
~CReleaser() { _c.Release(); }
};
CCoderMT(): EncodeMode(false) {}
~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);
};
class CMixerMT:
public IUnknown,
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;
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) Z7_override;
virtual UInt64 GetBondStreamSize(unsigned bondIndex) const Z7_override;
CMixerMT(bool encodeMode): CMixer(encodeMode) {}
};
#endif
}
#endif
@@ -0,0 +1,17 @@
// DummyOutStream.cpp
#include "StdAfx.h"
#include "DummyOutStream.h"
Z7_COM7F_IMF(CDummyOutStream::Write(const void *data, UInt32 size, UInt32 *processedSize))
{
UInt32 realProcessedSize = size;
HRESULT res = S_OK;
if (_stream)
res = _stream->Write(data, size, &realProcessedSize);
_size += realProcessedSize;
if (processedSize)
*processedSize = realProcessedSize;
return res;
}
@@ -0,0 +1,23 @@
// DummyOutStream.h
#ifndef ZIP7_INC_DUMMY_OUT_STREAM_H
#define ZIP7_INC_DUMMY_OUT_STREAM_H
#include "../../../Common/MyCom.h"
#include "../../IStream.h"
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; }
UInt64 GetSize() const { return _size; }
};
#endif
@@ -0,0 +1,90 @@
// FindSignature.cpp
#include "StdAfx.h"
#include <string.h>
#include "../../../Common/MyBuffer.h"
#include "../../Common/StreamUtils.h"
#include "FindSignature.h"
HRESULT FindSignatureInStream(ISequentialInStream *stream,
const Byte *signature, unsigned signatureSize,
const UInt64 *limit, UInt64 &resPos)
{
resPos = 0;
CByteBuffer byteBuffer2(signatureSize);
RINOK(ReadStream_FALSE(stream, byteBuffer2, signatureSize))
if (memcmp(byteBuffer2, signature, signatureSize) == 0)
return S_OK;
const size_t kBufferSize = 1 << 16;
CByteBuffer byteBuffer(kBufferSize);
Byte *buffer = byteBuffer;
size_t numPrevBytes = signatureSize - 1;
memcpy(buffer, (const Byte *)byteBuffer2 + 1, numPrevBytes);
resPos = 1;
for (;;)
{
if (limit)
if (resPos > *limit)
return S_FALSE;
do
{
const size_t numReadBytes = kBufferSize - numPrevBytes;
UInt32 processedSize;
RINOK(stream->Read(buffer + numPrevBytes, (UInt32)numReadBytes, &processedSize))
numPrevBytes += (size_t)processedSize;
if (processedSize == 0)
return S_FALSE;
}
while (numPrevBytes < signatureSize);
const size_t numTests = numPrevBytes - signatureSize + 1;
for (size_t pos = 0; pos < numTests; pos++)
{
const Byte b = signature[0];
for (; buffer[pos] != b && pos < numTests; pos++);
if (pos == numTests)
break;
if (memcmp(buffer + pos, signature, signatureSize) == 0)
{
resPos += pos;
return S_OK;
}
}
resPos += numTests;
numPrevBytes -= numTests;
memmove(buffer, buffer + numTests, numPrevBytes);
}
}
namespace NArchive {
HRESULT ReadZeroTail(ISequentialInStream *stream, bool &areThereNonZeros, UInt64 &numZeros, UInt64 maxSize);
HRESULT ReadZeroTail(ISequentialInStream *stream, bool &areThereNonZeros, UInt64 &numZeros, UInt64 maxSize)
{
areThereNonZeros = false;
numZeros = 0;
const size_t kBufSize = 1 << 11;
Byte buf[kBufSize];
for (;;)
{
UInt32 size = 0;
RINOK(stream->Read(buf, kBufSize, &size))
if (size == 0)
return S_OK;
for (UInt32 i = 0; i < size; i++)
if (buf[i] != 0)
{
areThereNonZeros = true;
numZeros += i;
return S_OK;
}
numZeros += size;
if (numZeros > maxSize)
return S_OK;
}
}
}
@@ -0,0 +1,12 @@
// FindSignature.h
#ifndef ZIP7_INC_FIND_SIGNATURE_H
#define ZIP7_INC_FIND_SIGNATURE_H
#include "../../IStream.h"
HRESULT FindSignatureInStream(ISequentialInStream *stream,
const Byte *signature, unsigned signatureSize,
const UInt64 *limit, UInt64 &resPos);
#endif
@@ -0,0 +1,315 @@
// HandlerOut.cpp
#include "StdAfx.h"
#include "../../../Common/StringToInt.h"
#include "HandlerOut.h"
namespace NArchive {
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::SetGlobalLevelTo(COneMethodInfo &oneMethodInfo) const
{
UInt32 level = _level;
if (level != (UInt32)(Int32)-1)
SetMethodProp32(oneMethodInfo, NCoderPropID::kLevel, (UInt32)level);
}
#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);
}
void CMultiMethodProps::SetMethodThreadsTo_Replace(CMethodProps &oneMethodInfo, UInt32 numThreads)
{
SetMethodProp32_Replace(oneMethodInfo, NCoderPropID::kNumThreads, numThreads);
}
void CMultiMethodProps::Set_Method_NumThreadGroups_IfNotFinded(CMethodProps &oneMethodInfo, UInt32 numThreadGroups)
{
SetMethodProp32(oneMethodInfo, NCoderPropID::kNumThreadGroups, numThreadGroups);
}
#endif // Z7_ST
void CMultiMethodProps::InitMulti()
{
_level = (UInt32)(Int32)-1;
_analysisLevel = -1;
_crcSize = 4;
_autoFilter = true;
}
void CMultiMethodProps::Init()
{
InitCommon();
InitMulti();
_methods.Clear();
_filterMethod.Clear();
}
HRESULT CMultiMethodProps::SetProperty(const wchar_t *nameSpec, const PROPVARIANT &value)
{
UString name = nameSpec;
name.MakeLower_Ascii();
if (name.IsEmpty())
return E_INVALIDARG;
if (name[0] == 'x')
{
name.Delete(0);
_level = 9;
return ParsePropToUInt32(name, value, _level);
}
if (name.IsPrefixedBy_Ascii_NoCase("yx"))
{
name.Delete(0, 2);
UInt32 v = 9;
RINOK(ParsePropToUInt32(name, value, v))
_analysisLevel = (int)v;
return S_OK;
}
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;
const unsigned index = ParseStringToUInt32(name, number);
const UString realName = name.Ptr(index);
if (index == 0)
{
if (name.IsEqualTo("f"))
{
const HRESULT res = PROPVARIANT_to_bool(value, _autoFilter);
if (res == S_OK)
return res;
if (value.vt != VT_BSTR)
return E_INVALIDARG;
return _filterMethod.ParseMethodFromPROPVARIANT(UString(), value);
}
number = 0;
}
if (number > 64)
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();
}
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++)
{
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;
}
}
@@ -0,0 +1,169 @@
// HandlerOut.h
#ifndef ZIP7_INC_HANDLER_OUT_H
#define ZIP7_INC_HANDLER_OUT_H
#include "../../../Windows/System.h"
#include "../../Common/MethodProps.h"
namespace NArchive {
bool ParseSizeString(const wchar_t *name, const PROPVARIANT &prop, UInt64 percentsBase, UInt64 &res);
class CCommonMethodProps
{
protected:
void InitCommon()
{
// _Write_MTime = true;
{
#ifndef Z7_ST
_numThreads_WasForced = false;
UInt32 numThreads;
#ifdef _WIN32
NWindows::NSystem::CProcessAffinity aff;
numThreads = aff.Load_and_GetNumberOfThreads();
_numThreadGroups = aff.IsGroupMode ? aff.Groups.GroupSizes.Size() : 0;
#else
numThreads = NWindows::NSystem::GetNumberOfProcessors();
#endif // _WIN32
_numProcessors = _numThreads = numThreads;
#endif // Z7_ST
}
size_t memAvail = (size_t)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 Z7_ST
UInt32 _numThreads;
UInt32 _numProcessors;
#ifdef _WIN32
UInt32 _numThreadGroups;
#endif
bool _numThreads_WasForced;
#endif
bool _memUsage_WasSet;
UInt64 _memUsage_Compress;
UInt64 _memUsage_Decompress;
size_t _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 SetGlobalLevelTo(COneMethodInfo &oneMethodInfo) const;
#ifndef Z7_ST
static void SetMethodThreadsTo_IfNotFinded(CMethodProps &props, UInt32 numThreads);
static void SetMethodThreadsTo_Replace(CMethodProps &props, UInt32 numThreads);
static void Set_Method_NumThreadGroups_IfNotFinded(CMethodProps &props, UInt32 numThreadGroups);
#endif
unsigned GetNumEmptyMethods() const
{
unsigned i;
for (i = 0; i < _methods.Size(); i++)
if (!_methods[i].IsEmpty())
break;
return i;
}
int GetLevel() const { return _level == (UInt32)(Int32)-1 ? 5 : (int)_level; }
int GetAnalysisLevel() const { return _analysisLevel; }
void Init();
CMultiMethodProps() { InitMulti(); }
HRESULT SetProperty(const wchar_t *name, const PROPVARIANT &value);
};
class CSingleMethodProps: public COneMethodInfo, public CCommonMethodProps
{
UInt32 _level;
void InitSingle()
{
_level = (UInt32)(Int32)-1;
}
public:
void 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
@@ -0,0 +1,57 @@
// InStreamWithCRC.cpp
#include "StdAfx.h"
#include "InStreamWithCRC.h"
Z7_COM7F_IMF(CSequentialInStreamWithCRC::Read(void *data, UInt32 size, UInt32 *processedSize))
{
UInt32 realProcessed = 0;
HRESULT result = S_OK;
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;
}
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;
if (_stream)
result = _stream->Read(data, size, &realProcessed);
_size += realProcessed;
/*
if (size != 0 && realProcessed == 0)
_wasFinished = true;
*/
_crc = CrcUpdate(_crc, data, realProcessed);
if (processedSize)
*processedSize = realProcessed;
return result;
}
Z7_COM7F_IMF(CInStreamWithCRC::Seek(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition))
{
if (seekOrigin != STREAM_SEEK_SET || offset != 0)
return E_FAIL;
_size = 0;
_crc = CRC_INIT_VAL;
return _stream->Seek(offset, seekOrigin, newPosition);
}
@@ -0,0 +1,64 @@
// InStreamWithCRC.h
#ifndef ZIP7_INC_IN_STREAM_WITH_CRC_H
#define ZIP7_INC_IN_STREAM_WITH_CRC_H
#include "../../../../C/7zCrc.h"
#include "../../../Common/MyCom.h"
#include "../../IStream.h"
Z7_CLASS_IMP_NOQIB_2(
CSequentialInStreamWithCRC
, ISequentialInStream
, IStreamGetSize
)
CMyComPtr<ISequentialInStream> _stream;
UInt64 _size;
UInt32 _crc;
bool _wasFinished;
UInt64 _fullSize;
public:
CSequentialInStreamWithCRC():
_fullSize((UInt64)(Int64)-1)
{}
void SetStream(ISequentialInStream *stream) { _stream = stream; }
void SetFullSize(UInt64 fullSize) { _fullSize = fullSize; }
void Init()
{
_size = 0;
_crc = CRC_INIT_VAL;
_wasFinished = false;
}
void ReleaseStream() { _stream.Release(); }
UInt32 GetCRC() const { return CRC_GET_DIGEST(_crc); }
UInt64 GetSize() const { return _size; }
bool WasFinished() const { return _wasFinished; }
};
Z7_CLASS_IMP_IInStream(
CInStreamWithCRC
)
CMyComPtr<IInStream> _stream;
UInt64 _size;
UInt32 _crc;
// bool _wasFinished;
public:
void SetStream(IInStream *stream) { _stream = stream; }
void Init()
{
_size = 0;
// _wasFinished = false;
_crc = CRC_INIT_VAL;
}
void ReleaseStream() { _stream.Release(); }
UInt32 GetCRC() const { return CRC_GET_DIGEST(_crc); }
UInt64 GetSize() const { return _size; }
// bool WasFinished() const { return _wasFinished; }
};
#endif
@@ -0,0 +1,140 @@
// Archive/Common/ItemNameUtils.cpp
#include "StdAfx.h"
#include "ItemNameUtils.h"
namespace NArchive {
namespace NItemName {
static const wchar_t kOsPathSepar = WCHAR_PATH_SEPARATOR;
#if WCHAR_PATH_SEPARATOR != L'/'
static const wchar_t kUnixPathSepar = L'/';
#endif
void ReplaceSlashes_OsToUnix
#if WCHAR_PATH_SEPARATOR != L'/'
(UString &name)
{
name.Replace(kOsPathSepar, kUnixPathSepar);
}
#else
(UString &) {}
#endif
UString GetOsPath(const UString &name)
{
#if WCHAR_PATH_SEPARATOR != L'/'
UString newName = name;
newName.Replace(kUnixPathSepar, kOsPathSepar);
return newName;
#else
return name;
#endif
}
UString GetOsPath_Remove_TailSlash(const UString &name)
{
if (name.IsEmpty())
return UString();
UString newName = GetOsPath(name);
if (newName.Back() == kOsPathSepar)
newName.DeleteBack();
return newName;
}
#if WCHAR_PATH_SEPARATOR != L'/'
void ReplaceToWinSlashes(UString &name, bool useBackslashReplacement)
{
// 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
void ReplaceToOsSlashes_Remove_TailSlash(UString &name, bool
#if WCHAR_PATH_SEPARATOR != L'/'
useBackslashReplacement
#endif
)
{
if (name.IsEmpty())
return;
#if WCHAR_PATH_SEPARATOR != L'/'
ReplaceToWinSlashes(name, useBackslashReplacement);
#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
#endif
)
{
if (name.IsEmpty())
return false;
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 WinPathToOsPath(const UString &name)
{
UString newName = name;
newName.Replace(L'\\', WCHAR_PATH_SEPARATOR);
return newName;
}
#endif
}}
@@ -0,0 +1,33 @@
// Archive/Common/ItemNameUtils.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 ReplaceSlashes_OsToUnix(UString &name);
UString GetOsPath(const UString &name);
UString GetOsPath_Remove_TailSlash(const UString &name);
#if WCHAR_PATH_SEPARATOR != L'/'
void ReplaceToWinSlashes(UString &name, bool useBackslashReplacement);
#endif
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
}}
#endif
@@ -0,0 +1,193 @@
// MultiStream.cpp
#include "StdAfx.h"
#include "MultiStream.h"
Z7_COM7F_IMF(CMultiStream::Read(void *data, UInt32 size, UInt32 *processedSize))
{
if (processedSize)
*processedSize = 0;
if (size == 0)
return S_OK;
if (_pos >= _totalLength)
return S_OK;
{
unsigned left = 0, mid = _streamIndex, right = Streams.Size();
for (;;)
{
CSubStreamInfo &m = Streams[mid];
if (_pos < m.GlobalOffset)
right = mid;
else if (_pos >= m.GlobalOffset + m.Size)
left = mid + 1;
else
break;
mid = (left + right) / 2;
}
_streamIndex = mid;
}
CSubStreamInfo &s = Streams[_streamIndex];
UInt64 localPos = _pos - s.GlobalOffset;
if (localPos != s.LocalPos)
{
RINOK(s.Stream->Seek((Int64)localPos, STREAM_SEEK_SET, &s.LocalPos))
}
{
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)
*processedSize = size;
return result;
}
Z7_COM7F_IMF(CMultiStream::Seek(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition))
{
switch (seekOrigin)
{
case STREAM_SEEK_SET: break;
case STREAM_SEEK_CUR: offset += _pos; break;
case STREAM_SEEK_END: offset += _totalLength; break;
default: return STG_E_INVALIDFUNCTION;
}
if (offset < 0)
return HRESULT_WIN32_ERROR_NEGATIVE_SEEK;
_pos = (UInt64)offset;
if (newPosition)
*newPosition = (UInt64)offset;
return S_OK;
}
/*
class COutVolumeStream:
public ISequentialOutStream,
public CMyUnknownImp
{
Z7_COM_UNKNOWN_IMP_0
Z7_IFACE_COM7_IMP(ISequentialOutStream)
unsigned _volIndex;
UInt64 _volSize;
UInt64 _curPos;
CMyComPtr<ISequentialOutStream> _volumeStream;
COutArchive _archive;
CCRC _crc;
public:
CFileItem _file;
CUpdateOptions _options;
CMyComPtr<IArchiveUpdateCallback2> VolumeCallback;
void Init(IArchiveUpdateCallback2 *volumeCallback,
const UString &name)
{
_file.Name = name;
_file.IsStartPosDefined = true;
_file.StartPos = 0;
VolumeCallback = volumeCallback;
_volIndex = 0;
_volSize = 0;
}
HRESULT Flush();
};
HRESULT COutVolumeStream::Flush()
{
if (_volumeStream)
{
_file.UnPackSize = _curPos;
_file.FileCRC = _crc.GetDigest();
RINOK(WriteVolumeHeader(_archive, _file, _options))
_archive.Close();
_volumeStream.Release();
_file.StartPos += _file.UnPackSize;
}
return S_OK;
}
*/
/*
#include "../../../Common/Defs.h"
Z7_COM7F_IMF(COutMultiStream::Write(const void *data, UInt32 size, UInt32 *processedSize))
{
if (processedSize)
*processedSize = 0;
while (size > 0)
{
if (_streamIndex >= Streams.Size())
{
CSubStreamInfo subStream;
RINOK(VolumeCallback->GetVolumeSize(Streams.Size(), &subStream.Size))
RINOK(VolumeCallback->GetVolumeStream(Streams.Size(), &subStream.Stream))
subStream.Pos = 0;
Streams.Add(subStream);
continue;
}
CSubStreamInfo &subStream = Streams[_streamIndex];
if (_offsetPos >= subStream.Size)
{
_offsetPos -= subStream.Size;
_streamIndex++;
continue;
}
if (_offsetPos != subStream.Pos)
{
CMyComPtr<IOutStream> outStream;
RINOK(subStream.Stream.QueryInterface(IID_IOutStream, &outStream))
RINOK(outStream->Seek((Int64)_offsetPos, STREAM_SEEK_SET, NULL))
subStream.Pos = _offsetPos;
}
const UInt32 curSize = (UInt32)MyMin((UInt64)size, subStream.Size - subStream.Pos);
UInt32 realProcessed;
RINOK(subStream.Stream->Write(data, curSize, &realProcessed))
data = (const void *)((const Byte *)data + realProcessed);
size -= realProcessed;
subStream.Pos += realProcessed;
_offsetPos += realProcessed;
_absPos += realProcessed;
if (_absPos > _length)
_length = _absPos;
if (processedSize)
*processedSize += realProcessed;
if (subStream.Pos == subStream.Size)
{
_streamIndex++;
_offsetPos = 0;
}
if (realProcessed != curSize && realProcessed == 0)
return E_FAIL;
}
return S_OK;
}
Z7_COM7F_IMF(COutMultiStream::Seek(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition))
{
switch (seekOrigin)
{
case STREAM_SEEK_SET: break;
case STREAM_SEEK_CUR: offset += _absPos; break;
case STREAM_SEEK_END: offset += _length; break;
default: return STG_E_INVALIDFUNCTION;
}
if (offset < 0)
return HRESULT_WIN32_ERROR_NEGATIVE_SEEK;
_absPos = (UInt64)offset;
_offsetPos = _absPos;
_streamIndex = 0;
if (newPosition)
*newPosition = (UInt64)offset;
return S_OK;
}
*/
@@ -0,0 +1,86 @@
// MultiStream.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"
Z7_CLASS_IMP_IInStream(
CMultiStream
)
unsigned _streamIndex;
UInt64 _pos;
UInt64 _totalLength;
public:
struct CSubStreamInfo
{
CMyComPtr<IInStream> Stream;
UInt64 Size;
UInt64 GlobalOffset;
UInt64 LocalPos;
CSubStreamInfo(): Size(0), GlobalOffset(0), LocalPos(0) {}
};
CMyComPtr<IArchiveUpdateCallbackFile> updateCallbackFile;
CObjectVector<CSubStreamInfo> Streams;
HRESULT Init()
{
UInt64 total = 0;
FOR_VECTOR (i, Streams)
{
CSubStreamInfo &s = Streams[i];
s.GlobalOffset = total;
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;
}
};
/*
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;
UInt64 _length;
struct CSubStreamInfo
{
CMyComPtr<ISequentialOutStream> Stream;
UInt64 Size;
UInt64 Pos;
};
CObjectVector<CSubStreamInfo> Streams;
public:
CMyComPtr<IArchiveUpdateCallback2> VolumeCallback;
void Init()
{
_streamIndex = 0;
_offsetPos = 0;
_absPos = 0;
_length = 0;
}
};
*/
#endif
@@ -0,0 +1,18 @@
// OutStreamWithCRC.cpp
#include "StdAfx.h"
#include "OutStreamWithCRC.h"
Z7_COM7F_IMF(COutStreamWithCRC::Write(const void *data, UInt32 size, UInt32 *processedSize))
{
HRESULT result = S_OK;
if (_stream)
result = _stream->Write(data, size, &size);
if (_calculate)
_crc = CrcUpdate(_crc, data, size);
_size += size;
if (processedSize)
*processedSize = size;
return result;
}
@@ -0,0 +1,35 @@
// OutStreamWithCRC.h
#ifndef ZIP7_INC_OUT_STREAM_WITH_CRC_H
#define ZIP7_INC_OUT_STREAM_WITH_CRC_H
#include "../../../../C/7zCrc.h"
#include "../../../Common/MyCom.h"
#include "../../IStream.h"
Z7_CLASS_IMP_NOQIB_1(
COutStreamWithCRC
, ISequentialOutStream
)
CMyComPtr<ISequentialOutStream> _stream;
UInt64 _size;
UInt32 _crc;
bool _calculate;
public:
void SetStream(ISequentialOutStream *stream) { _stream = stream; }
void ReleaseStream() { _stream.Release(); }
void Init(bool calculate = true)
{
_size = 0;
_calculate = calculate;
_crc = CRC_INIT_VAL;
}
void EnableCalc(bool calculate) { _calculate = calculate; }
void InitCRC() { _crc = CRC_INIT_VAL; }
UInt64 GetSize() const { return _size; }
UInt32 GetCRC() const { return CRC_GET_DIGEST(_crc); }
};
#endif
@@ -0,0 +1,29 @@
// OutStreamWithSha1.cpp
#include "StdAfx.h"
#include "OutStreamWithSha1.h"
Z7_COM7F_IMF(COutStreamWithSha1::Write(const void *data, UInt32 size, UInt32 *processedSize))
{
HRESULT result = S_OK;
if (_stream)
result = _stream->Write(data, size, &size);
if (_calculate)
Sha1_Update(Sha(), (const Byte *)data, size);
_size += size;
if (processedSize)
*processedSize = size;
return result;
}
Z7_COM7F_IMF(CInStreamWithSha1::Read(void *data, UInt32 size, UInt32 *processedSize))
{
UInt32 realProcessedSize;
const HRESULT result = _stream->Read(data, size, &realProcessedSize);
_size += realProcessedSize;
Sha1_Update(Sha(), (const Byte *)data, realProcessedSize);
if (processedSize)
*processedSize = realProcessedSize;
return result;
}
@@ -0,0 +1,61 @@
// OutStreamWithSha1.h
#ifndef ZIP7_INC_OUT_STREAM_WITH_SHA1_H
#define ZIP7_INC_OUT_STREAM_WITH_SHA1_H
#include "../../../../C/Sha1.h"
#include "../../../Common/MyBuffer2.h"
#include "../../../Common/MyCom.h"
#include "../../IStream.h"
Z7_CLASS_IMP_NOQIB_1(
COutStreamWithSha1
, ISequentialOutStream
)
bool _calculate;
CMyComPtr<ISequentialOutStream> _stream;
CAlignedBuffer1 _sha;
UInt64 _size;
CSha1 *Sha() { return (CSha1 *)(void *)(Byte *)_sha; }
public:
COutStreamWithSha1(): _sha(sizeof(CSha1)) {}
void SetStream(ISequentialOutStream *stream) { _stream = stream; }
void ReleaseStream() { _stream.Release(); }
void Init(bool calculate = true)
{
_calculate = calculate;
_size = 0;
Sha1_Init(Sha());
}
void InitSha1() { Sha1_Init(Sha()); }
UInt64 GetSize() const { return _size; }
void Final(Byte *digest) { Sha1_Final(Sha(), digest); }
};
Z7_CLASS_IMP_NOQIB_1(
CInStreamWithSha1
, ISequentialInStream
)
CMyComPtr<ISequentialInStream> _stream;
CAlignedBuffer1 _sha;
UInt64 _size;
CSha1 *Sha() { return (CSha1 *)(void *)(Byte *)_sha; }
public:
CInStreamWithSha1(): _sha(sizeof(CSha1)) {}
void SetStream(ISequentialInStream *stream) { _stream = stream; }
void Init()
{
_size = 0;
Sha1_Init(Sha());
}
void ReleaseStream() { _stream.Release(); }
UInt64 GetSize() const { return _size; }
void Final(Byte *digest) { Sha1_Final(Sha(), digest); }
};
#endif
@@ -0,0 +1,3 @@
// ParseProperties.cpp
#include "StdAfx.h"
@@ -0,0 +1,6 @@
// ParseProperties.h
#ifndef ZIP7_INC_PARSE_PROPERTIES_H
#define ZIP7_INC_PARSE_PROPERTIES_H
#endif
@@ -0,0 +1,11 @@
// 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