diff options
author | kh1 <karsten.heimrich@digia.com> | 2013-05-02 15:28:22 +0200 |
---|---|---|
committer | Karsten Heimrich <karsten.heimrich@digia.com> | 2013-05-08 13:01:55 +0200 |
commit | d89674f944c419c9473da688993ee69671f2c295 (patch) | |
tree | 8422461a5b45d97b6d32dfa8e060e69d600210c9 /src/libs/7zip/win/CPP/7zip/Archive/Common | |
parent | 5ed380ebcf8ef1157f651cbdef8393ccac897ee2 (diff) |
Reset to only use the basic LZMA SDK (Windows).
Change-Id: I8088cc4775f6c5397991f00512354836d614ea4e
Reviewed-by: Kai Koehne <kai.koehne@digia.com>
Reviewed-by: Tim Jenssen <tim.jenssen@digia.com>
Diffstat (limited to 'src/libs/7zip/win/CPP/7zip/Archive/Common')
10 files changed, 0 insertions, 674 deletions
diff --git a/src/libs/7zip/win/CPP/7zip/Archive/Common/CoderMixer.cpp b/src/libs/7zip/win/CPP/7zip/Archive/Common/CoderMixer.cpp deleted file mode 100644 index a19f04579..000000000 --- a/src/libs/7zip/win/CPP/7zip/Archive/Common/CoderMixer.cpp +++ /dev/null @@ -1,19 +0,0 @@ -// CoderMixer.cpp - -#include "StdAfx.h" - -#include "CoderMixer.h" - -namespace NCoderMixer { - -void CCoderInfo::SetCoderInfo(const UInt64 *inSize, const UInt64 *outSize) -{ - InSizeAssigned = (inSize != 0); - if (InSizeAssigned) - InSizeValue = *inSize; - OutSizeAssigned = (outSize != 0); - if (OutSizeAssigned) - OutSizeValue = *outSize; -} - -} diff --git a/src/libs/7zip/win/CPP/7zip/Archive/Common/CoderMixer.h b/src/libs/7zip/win/CPP/7zip/Archive/Common/CoderMixer.h deleted file mode 100644 index 6379dd808..000000000 --- a/src/libs/7zip/win/CPP/7zip/Archive/Common/CoderMixer.h +++ /dev/null @@ -1,32 +0,0 @@ -// CoderMixer.h - -#ifndef __CODER_MIXER_H -#define __CODER_MIXER_H - -#include "../../../Common/MyCom.h" -#include "../../ICoder.h" - -namespace NCoderMixer { - -struct CCoderInfo -{ - CMyComPtr<ICompressCoder> Coder; - CMyComPtr<ISequentialInStream> InStream; - CMyComPtr<ISequentialOutStream> OutStream; - CMyComPtr<ICompressProgressInfo> Progress; - - UInt64 InSizeValue; - UInt64 OutSizeValue; - bool InSizeAssigned; - bool OutSizeAssigned; - - void ReInit() - { - InSizeAssigned = OutSizeAssigned = false; - } - - void SetCoderInfo(const UInt64 *inSize, const UInt64 *outSize); -}; - -} -#endif diff --git a/src/libs/7zip/win/CPP/7zip/Archive/Common/CoderMixer2ST.cpp b/src/libs/7zip/win/CPP/7zip/Archive/Common/CoderMixer2ST.cpp deleted file mode 100644 index a59ce5fc0..000000000 --- a/src/libs/7zip/win/CPP/7zip/Archive/Common/CoderMixer2ST.cpp +++ /dev/null @@ -1,239 +0,0 @@ -// CoderMixer2ST.cpp - -#include "StdAfx.h" - -#include "CoderMixer2ST.h" - -namespace NCoderMixer2 { - -CCoderMixer2ST::CCoderMixer2ST() {} - -CCoderMixer2ST::~CCoderMixer2ST(){ } - -HRESULT CCoderMixer2ST::SetBindInfo(const CBindInfo &bindInfo) -{ - _bindInfo = bindInfo; - return S_OK; -} - -void CCoderMixer2ST::AddCoderCommon(bool isMain) -{ - const CCoderStreamsInfo &csi = _bindInfo.Coders[_coders.Size()]; - _coders.Add(CSTCoderInfo(csi.NumInStreams, csi.NumOutStreams, isMain)); -} - -void CCoderMixer2ST::AddCoder(ICompressCoder *coder, bool isMain) -{ - AddCoderCommon(isMain); - _coders.Back().Coder = coder; -} - -void CCoderMixer2ST::AddCoder2(ICompressCoder2 *coder, bool isMain) -{ - AddCoderCommon(isMain); - _coders.Back().Coder2 = coder; -} - -void CCoderMixer2ST::ReInit() { } - -HRESULT CCoderMixer2ST::GetInStream( - ISequentialInStream **inStreams, const UInt64 **inSizes, - UInt32 streamIndex, ISequentialInStream **inStreamRes) -{ - CMyComPtr<ISequentialInStream> seqInStream; - int i; - for(i = 0; i < _bindInfo.InStreams.Size(); i++) - if (_bindInfo.InStreams[i] == streamIndex) - { - seqInStream = inStreams[i]; - *inStreamRes = seqInStream.Detach(); - return S_OK; - } - int binderIndex = _bindInfo.FindBinderForInStream(streamIndex); - if (binderIndex < 0) - return E_INVALIDARG; - - UInt32 coderIndex, coderStreamIndex; - _bindInfo.FindOutStream(_bindInfo.BindPairs[binderIndex].OutIndex, - coderIndex, coderStreamIndex); - - CCoderInfo &coder = _coders[coderIndex]; - if (!coder.Coder) - return E_NOTIMPL; - coder.Coder.QueryInterface(IID_ISequentialInStream, &seqInStream); - if (!seqInStream) - return E_NOTIMPL; - - UInt32 startIndex = _bindInfo.GetCoderInStreamIndex(coderIndex); - - CMyComPtr<ICompressSetInStream> setInStream; - if (!coder.Coder) - return E_NOTIMPL; - coder.Coder.QueryInterface(IID_ICompressSetInStream, &setInStream); - if (!setInStream) - return E_NOTIMPL; - - if (coder.NumInStreams > 1) - return E_NOTIMPL; - for (i = 0; i < (int)coder.NumInStreams; i++) - { - CMyComPtr<ISequentialInStream> seqInStream2; - RINOK(GetInStream(inStreams, inSizes, startIndex + i, &seqInStream2)); - RINOK(setInStream->SetInStream(seqInStream2)); - } - *inStreamRes = seqInStream.Detach(); - return S_OK; -} - -HRESULT CCoderMixer2ST::GetOutStream( - ISequentialOutStream **outStreams, const UInt64 **outSizes, - UInt32 streamIndex, ISequentialOutStream **outStreamRes) -{ - CMyComPtr<ISequentialOutStream> seqOutStream; - int i; - for(i = 0; i < _bindInfo.OutStreams.Size(); i++) - if (_bindInfo.OutStreams[i] == streamIndex) - { - seqOutStream = outStreams[i]; - *outStreamRes = seqOutStream.Detach(); - return S_OK; - } - int binderIndex = _bindInfo.FindBinderForOutStream(streamIndex); - if (binderIndex < 0) - return E_INVALIDARG; - - UInt32 coderIndex, coderStreamIndex; - _bindInfo.FindInStream(_bindInfo.BindPairs[binderIndex].InIndex, - coderIndex, coderStreamIndex); - - CCoderInfo &coder = _coders[coderIndex]; - if (!coder.Coder) - return E_NOTIMPL; - coder.Coder.QueryInterface(IID_ISequentialOutStream, &seqOutStream); - if (!seqOutStream) - return E_NOTIMPL; - - UInt32 startIndex = _bindInfo.GetCoderOutStreamIndex(coderIndex); - - CMyComPtr<ICompressSetOutStream> setOutStream; - if (!coder.Coder) - return E_NOTIMPL; - coder.Coder.QueryInterface(IID_ICompressSetOutStream, &setOutStream); - if (!setOutStream) - return E_NOTIMPL; - - if (coder.NumOutStreams > 1) - return E_NOTIMPL; - for (i = 0; i < (int)coder.NumOutStreams; i++) - { - CMyComPtr<ISequentialOutStream> seqOutStream2; - RINOK(GetOutStream(outStreams, outSizes, startIndex + i, &seqOutStream2)); - RINOK(setOutStream->SetOutStream(seqOutStream2)); - } - *outStreamRes = seqOutStream.Detach(); - return S_OK; -} - - -STDMETHODIMP CCoderMixer2ST::Code(ISequentialInStream **inStreams, - const UInt64 **inSizes, - UInt32 numInStreams, - ISequentialOutStream **outStreams, - const UInt64 **outSizes, - UInt32 numOutStreams, - ICompressProgressInfo *progress) -{ - if (numInStreams != (UInt32)_bindInfo.InStreams.Size() || - numOutStreams != (UInt32)_bindInfo.OutStreams.Size()) - return E_INVALIDARG; - - // Find main coder - int _mainCoderIndex = -1; - int i; - for (i = 0; i < _coders.Size(); i++) - if (_coders[i].IsMain) - { - _mainCoderIndex = i; - break; - } - if (_mainCoderIndex < 0) - for (i = 0; i < _coders.Size(); i++) - if (_coders[i].NumInStreams > 1) - { - if (_mainCoderIndex >= 0) - return E_NOTIMPL; - _mainCoderIndex = i; - } - if (_mainCoderIndex < 0) - _mainCoderIndex = 0; - - // _mainCoderIndex = 0; - // _mainCoderIndex = _coders.Size() - 1; - CCoderInfo &mainCoder = _coders[_mainCoderIndex]; - - CObjectVector< CMyComPtr<ISequentialInStream> > seqInStreams; - CObjectVector< CMyComPtr<ISequentialOutStream> > seqOutStreams; - UInt32 startInIndex = _bindInfo.GetCoderInStreamIndex(_mainCoderIndex); - UInt32 startOutIndex = _bindInfo.GetCoderOutStreamIndex(_mainCoderIndex); - for (i = 0; i < (int)mainCoder.NumInStreams; i++) - { - CMyComPtr<ISequentialInStream> seqInStream; - RINOK(GetInStream(inStreams, inSizes, startInIndex + i, &seqInStream)); - seqInStreams.Add(seqInStream); - } - for (i = 0; i < (int)mainCoder.NumOutStreams; i++) - { - CMyComPtr<ISequentialOutStream> seqOutStream; - RINOK(GetOutStream(outStreams, outSizes, startOutIndex + i, &seqOutStream)); - seqOutStreams.Add(seqOutStream); - } - CRecordVector< ISequentialInStream * > seqInStreamsSpec; - CRecordVector< ISequentialOutStream * > seqOutStreamsSpec; - for (i = 0; i < (int)mainCoder.NumInStreams; i++) - seqInStreamsSpec.Add(seqInStreams[i]); - for (i = 0; i < (int)mainCoder.NumOutStreams; i++) - seqOutStreamsSpec.Add(seqOutStreams[i]); - - for (i = 0; i < _coders.Size(); i++) - { - if (i == _mainCoderIndex) - continue; - CCoderInfo &coder = _coders[i]; - CMyComPtr<ICompressSetOutStreamSize> setOutStreamSize; - coder.Coder.QueryInterface(IID_ICompressSetOutStreamSize, &setOutStreamSize); - if (setOutStreamSize) - { - RINOK(setOutStreamSize->SetOutStreamSize(coder.OutSizePointers[0])); - } - } - if (mainCoder.Coder) - { - RINOK(mainCoder.Coder->Code( - seqInStreamsSpec[0], seqOutStreamsSpec[0], - mainCoder.InSizePointers[0], mainCoder.OutSizePointers[0], - progress)); - } - else - { - RINOK(mainCoder.Coder2->Code( - &seqInStreamsSpec.Front(), - &mainCoder.InSizePointers.Front(), mainCoder.NumInStreams, - &seqOutStreamsSpec.Front(), - &mainCoder.OutSizePointers.Front(), mainCoder.NumOutStreams, - progress)); - } - CMyComPtr<IOutStreamFlush> flush; - seqOutStreams.Front().QueryInterface(IID_IOutStreamFlush, &flush); - if (flush) - return flush->Flush(); - return S_OK; -} - -/* -UInt64 CCoderMixer2ST::GetWriteProcessedSize(UInt32 binderIndex) const -{ - return _streamBinders[binderIndex].ProcessedSize; -} -*/ - -} diff --git a/src/libs/7zip/win/CPP/7zip/Archive/Common/CoderMixer2ST.h b/src/libs/7zip/win/CPP/7zip/Archive/Common/CoderMixer2ST.h deleted file mode 100644 index a4ea7e80d..000000000 --- a/src/libs/7zip/win/CPP/7zip/Archive/Common/CoderMixer2ST.h +++ /dev/null @@ -1,88 +0,0 @@ -// CoderMixer2ST.h - -#ifndef __CODER_MIXER2_ST_H -#define __CODER_MIXER2_ST_H - -#include "CoderMixer2.h" -#include "../../../Common/MyCom.h" -#include "../../ICoder.h" - -namespace NCoderMixer2 { - -// SetBindInfo() -// for each coder -// { -// AddCoder[2]() -// } -// -// for each file -// { -// ReInit() -// for each coder -// { -// SetCoderInfo -// } -// SetProgressIndex(UInt32 coderIndex); -// Code -// } - -struct CSTCoderInfo: public CCoderInfo -{ - bool IsMain; - CSTCoderInfo(UInt32 numInStreams, UInt32 numOutStreams, bool isMain): - CCoderInfo(numInStreams, numOutStreams),IsMain(isMain) {} -}; - -class CCoderMixer2ST: - public ICompressCoder2, - public CCoderMixer2, - public CMyUnknownImp -{ - MY_UNKNOWN_IMP - - HRESULT GetInStream( - ISequentialInStream **inStreams, const UInt64 **inSizes, - UInt32 streamIndex, ISequentialInStream **inStreamRes); - HRESULT GetOutStream( - ISequentialOutStream **outStreams, const UInt64 **outSizes, - UInt32 streamIndex, ISequentialOutStream **outStreamRes); -public: - STDMETHOD(Code)(ISequentialInStream **inStreams, - const UInt64 **inSizes, - UInt32 numInStreams, - ISequentialOutStream **outStreams, - const UInt64 **outSizes, - UInt32 numOutStreams, - ICompressProgressInfo *progress); - - CCoderMixer2ST(); - ~CCoderMixer2ST(); - void AddCoderCommon(bool isMain); - void AddCoder(ICompressCoder *coder, bool isMain); - void AddCoder2(ICompressCoder2 *coder, bool isMain); - - void ReInit(); - void SetCoderInfo(UInt32 coderIndex, const UInt64 **inSizes, const UInt64 **outSizes) - { - { _coders[coderIndex].SetCoderInfo(inSizes, outSizes); } - } - - void SetProgressCoderIndex(UInt32 /*coderIndex*/) - { - // _progressCoderIndex = coderIndex; - } - - // UInt64 GetWriteProcessedSize(UInt32 binderIndex) const; - -private: - CBindInfo _bindInfo; - CObjectVector<CSTCoderInfo> _coders; - int _mainCoderIndex; -public: - HRESULT SetBindInfo(const CBindInfo &bindInfo); - -}; - -} -#endif - diff --git a/src/libs/7zip/win/CPP/7zip/Archive/Common/CoderMixerMT.cpp b/src/libs/7zip/win/CPP/7zip/Archive/Common/CoderMixerMT.cpp deleted file mode 100644 index f43d1612d..000000000 --- a/src/libs/7zip/win/CPP/7zip/Archive/Common/CoderMixerMT.cpp +++ /dev/null @@ -1,99 +0,0 @@ -// CoderMixerMT.cpp - -#include "StdAfx.h" - -#include "CoderMixerMT.h" - -namespace NCoderMixer { - -void CCoder::Execute() { Code(NULL); } - -void CCoder::Code(ICompressProgressInfo *progress) -{ - Result = Coder->Code(InStream, OutStream, - InSizeAssigned ? &InSizeValue : NULL, - OutSizeAssigned ? &OutSizeValue : NULL, - progress); - InStream.Release(); - OutStream.Release(); -} - -void CCoderMixerMT::AddCoder(ICompressCoder *coder) -{ - _coders.Add(CCoder()); - _coders.Back().Coder = coder; -} - -void CCoderMixerMT::ReInit() -{ - for(int i = 0; i < _coders.Size(); i++) - _coders[i].ReInit(); -} - -HRESULT CCoderMixerMT::ReturnIfError(HRESULT code) -{ - for (int i = 0; i < _coders.Size(); i++) - if (_coders[i].Result == code) - return code; - return S_OK; -} - -STDMETHODIMP CCoderMixerMT::Code(ISequentialInStream *inStream, - ISequentialOutStream *outStream, - const UInt64 * /* inSize */, const UInt64 * /* outSize */, - ICompressProgressInfo *progress) -{ - _coders.Front().InStream = inStream; - int i; - _coders.Back().OutStream = outStream; - - for (i = 0; i < _coders.Size(); i++) - if (i != _progressCoderIndex) - { - RINOK(_coders[i].Create()); - } - - _streamBinders.Clear(); - for (i = 0; i + 1 < _coders.Size(); i++) - { - _streamBinders.Add(CStreamBinder()); - CStreamBinder &sb = _streamBinders[i]; - RINOK(sb.CreateEvents()); - sb.CreateStreams(&_coders[i + 1].InStream, &_coders[i].OutStream); - } - - for(i = 0; i < _streamBinders.Size(); i++) - _streamBinders[i].ReInit(); - - for (i = 0; i < _coders.Size(); i++) - if (i != _progressCoderIndex) - _coders[i].Start(); - - _coders[_progressCoderIndex].Code(progress); - - for (i = 0; i < _coders.Size(); i++) - if (i != _progressCoderIndex) - _coders[i].WaitFinish(); - - RINOK(ReturnIfError(E_ABORT)); - RINOK(ReturnIfError(E_OUTOFMEMORY)); - - for (i = 0; i < _coders.Size(); i++) - { - HRESULT result = _coders[i].Result; - if (result != S_OK && result != E_FAIL && result != S_FALSE) - return result; - } - - RINOK(ReturnIfError(S_FALSE)); - - for (i = 0; i < _coders.Size(); i++) - { - HRESULT result = _coders[i].Result; - if (result != S_OK) - return result; - } - return S_OK; -} - -} diff --git a/src/libs/7zip/win/CPP/7zip/Archive/Common/CoderMixerMT.h b/src/libs/7zip/win/CPP/7zip/Archive/Common/CoderMixerMT.h deleted file mode 100644 index c70e1829f..000000000 --- a/src/libs/7zip/win/CPP/7zip/Archive/Common/CoderMixerMT.h +++ /dev/null @@ -1,69 +0,0 @@ -// CoderMixerMT.h - -#ifndef __CODER_MIXER_MT_H -#define __CODER_MIXER_MT_H - -#include "../../../Common/MyVector.h" -#include "../../../Common/MyCom.h" -#include "../../ICoder.h" -#include "../../Common/StreamBinder.h" -#include "../../Common/VirtThread.h" -#include "CoderMixer.h" - -namespace NCoderMixer { - -struct CCoder: public CCoderInfo, public CVirtThread -{ - HRESULT Result; - - virtual void Execute(); - void Code(ICompressProgressInfo *progress); -}; - -/* - for each coder - AddCoder() - SetProgressIndex(UInt32 coderIndex); - - for each file - { - ReInit() - for each coder - SetCoderInfo - Code - } -*/ - - -class CCoderMixerMT: - public ICompressCoder, - public CMyUnknownImp -{ - CObjectVector<CStreamBinder> _streamBinders; - int _progressCoderIndex; - - HRESULT ReturnIfError(HRESULT code); -public: - CObjectVector<CCoder> _coders; - MY_UNKNOWN_IMP - - STDMETHOD(Code)(ISequentialInStream *inStream, - ISequentialOutStream *outStream, - const UInt64 *inSize, const UInt64 *outSize, - ICompressProgressInfo *progress); - - void AddCoder(ICompressCoder *coder); - void SetProgressCoderIndex(int coderIndex) { _progressCoderIndex = coderIndex; } - - void ReInit(); - void SetCoderInfo(UInt32 coderIndex, const UInt64 *inSize, const UInt64 *outSize) - { _coders[coderIndex].SetCoderInfo(inSize, outSize); } - - /* - UInt64 GetWriteProcessedSize(UInt32 binderIndex) const - { return _streamBinders[binderIndex].ProcessedSize; } - */ -}; - -} -#endif diff --git a/src/libs/7zip/win/CPP/7zip/Archive/Common/FindSignature.cpp b/src/libs/7zip/win/CPP/7zip/Archive/Common/FindSignature.cpp deleted file mode 100644 index 15aa6ceae..000000000 --- a/src/libs/7zip/win/CPP/7zip/Archive/Common/FindSignature.cpp +++ /dev/null @@ -1,62 +0,0 @@ -// FindSignature.cpp - -#include "StdAfx.h" - -#include "Common/Buffer.h" - -#include "FindSignature.h" - -#include "../../Common/StreamUtils.h" - -HRESULT FindSignatureInStream(ISequentialInStream *stream, - const Byte *signature, unsigned signatureSize, - const UInt64 *limit, UInt64 &resPos) -{ - resPos = 0; - CByteBuffer byteBuffer2; - byteBuffer2.SetCapacity(signatureSize); - RINOK(ReadStream_FALSE(stream, byteBuffer2, signatureSize)); - - if (memcmp(byteBuffer2, signature, signatureSize) == 0) - return S_OK; - - const UInt32 kBufferSize = (1 << 16); - CByteBuffer byteBuffer; - byteBuffer.SetCapacity(kBufferSize); - Byte *buffer = byteBuffer; - UInt32 numPrevBytes = signatureSize - 1; - memcpy(buffer, (const Byte *)byteBuffer2 + 1, numPrevBytes); - resPos = 1; - for (;;) - { - if (limit != NULL) - if (resPos > *limit) - return S_FALSE; - do - { - UInt32 numReadBytes = kBufferSize - numPrevBytes; - UInt32 processedSize; - RINOK(stream->Read(buffer + numPrevBytes, numReadBytes, &processedSize)); - numPrevBytes += processedSize; - if (processedSize == 0) - return S_FALSE; - } - while (numPrevBytes < signatureSize); - UInt32 numTests = numPrevBytes - signatureSize + 1; - for (UInt32 pos = 0; pos < numTests; pos++) - { - 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); - } -} diff --git a/src/libs/7zip/win/CPP/7zip/Archive/Common/FindSignature.h b/src/libs/7zip/win/CPP/7zip/Archive/Common/FindSignature.h deleted file mode 100644 index e15af5732..000000000 --- a/src/libs/7zip/win/CPP/7zip/Archive/Common/FindSignature.h +++ /dev/null @@ -1,12 +0,0 @@ -// FindSignature.h - -#ifndef __FINDSIGNATURE_H -#define __FINDSIGNATURE_H - -#include "../../IStream.h" - -HRESULT FindSignatureInStream(ISequentialInStream *stream, - const Byte *signature, unsigned signatureSize, - const UInt64 *limit, UInt64 &resPos); - -#endif diff --git a/src/libs/7zip/win/CPP/7zip/Archive/Common/OutStreamWithSha1.cpp b/src/libs/7zip/win/CPP/7zip/Archive/Common/OutStreamWithSha1.cpp deleted file mode 100644 index 0526c1b1d..000000000 --- a/src/libs/7zip/win/CPP/7zip/Archive/Common/OutStreamWithSha1.cpp +++ /dev/null @@ -1,18 +0,0 @@ -// OutStreamWithSha1.cpp - -#include "StdAfx.h" - -#include "OutStreamWithSha1.h" - -STDMETHODIMP COutStreamWithSha1::Write(const void *data, UInt32 size, UInt32 *processedSize) -{ - HRESULT result = S_OK; - if (_stream) - result = _stream->Write(data, size, &size); - if (_calculate) - _sha.Update((const Byte *)data, size); - _size += size; - if (processedSize != NULL) - *processedSize = size; - return result; -} diff --git a/src/libs/7zip/win/CPP/7zip/Archive/Common/OutStreamWithSha1.h b/src/libs/7zip/win/CPP/7zip/Archive/Common/OutStreamWithSha1.h deleted file mode 100644 index 3bbfbbe19..000000000 --- a/src/libs/7zip/win/CPP/7zip/Archive/Common/OutStreamWithSha1.h +++ /dev/null @@ -1,36 +0,0 @@ -// OutStreamWithSha1.h - -#ifndef __OUT_STREAM_WITH_SHA1_H -#define __OUT_STREAM_WITH_SHA1_H - -#include "../../Crypto/Sha1.h" - -#include "../../../Common/MyCom.h" - -#include "../../IStream.h" - -class COutStreamWithSha1: - public ISequentialOutStream, - public CMyUnknownImp -{ - CMyComPtr<ISequentialOutStream> _stream; - UInt64 _size; - NCrypto::NSha1::CContext _sha; - 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) - { - _size = 0; - _calculate = calculate; - _sha.Init(); - } - void InitSha1() { _sha.Init(); } - UInt64 GetSize() const { return _size; } - void Final(Byte *digest) { _sha.Final(digest); } -}; - -#endif |