diff options
author | Igor Pavlov <ipavlov@users.sourceforge.net> | 2007-08-27 04:00:00 +0400 |
---|---|---|
committer | Kornel LesiĆski <kornel@geekhood.net> | 2016-05-28 02:15:54 +0300 |
commit | 051769bbc577aeede90558b6ab5c9be187940ca0 (patch) | |
tree | e6330cb80f2d4a526d8aa27812528e053b0cda90 /CPP/7zip/Archive/Common | |
parent | 33ccab7e728a996800e166d849fe1e92a17e1afe (diff) |
4.53 beta
Diffstat (limited to 'CPP/7zip/Archive/Common')
-rwxr-xr-x | CPP/7zip/Archive/Common/CoderMixer2MT.cpp | 24 | ||||
-rwxr-xr-x | CPP/7zip/Archive/Common/CoderMixer2MT.h | 1 | ||||
-rwxr-xr-x | CPP/7zip/Archive/Common/CoderMixerMT.cpp | 24 | ||||
-rwxr-xr-x | CPP/7zip/Archive/Common/CoderMixerMT.h | 1 | ||||
-rwxr-xr-x | CPP/7zip/Archive/Common/DummyOutStream.cpp | 24 | ||||
-rwxr-xr-x | CPP/7zip/Archive/Common/DummyOutStream.h | 10 |
6 files changed, 44 insertions, 40 deletions
diff --git a/CPP/7zip/Archive/Common/CoderMixer2MT.cpp b/CPP/7zip/Archive/Common/CoderMixer2MT.cpp index a297eb7f..2ef1fa95 100755 --- a/CPP/7zip/Archive/Common/CoderMixer2MT.cpp +++ b/CPP/7zip/Archive/Common/CoderMixer2MT.cpp @@ -167,6 +167,14 @@ HRESULT CCoderMixer2MT::Init(ISequentialInStream **inStreams, ISequentialOutStre return S_OK; } +HRESULT CCoderMixer2MT::ReturnIfError(HRESULT code) +{ + for (int i = 0; i < _coders.Size(); i++) + if (_coders[i].Result == code) + return code; + return S_OK; +} + STDMETHODIMP CCoderMixer2MT::Code(ISequentialInStream **inStreams, const UInt64 ** /* inSizes */, UInt32 numInStreams, @@ -198,18 +206,10 @@ STDMETHODIMP CCoderMixer2MT::Code(ISequentialInStream **inStreams, if (i != _progressCoderIndex) _coders[i].WaitFinish(); - for (i = 0; i < _coders.Size(); i++) - { - HRESULT result = _coders[i].Result; - if (result == E_ABORT) - return result; - } - for (i = 0; i < _coders.Size(); i++) - { - HRESULT result = _coders[i].Result; - if (result == S_FALSE) - return result; - } + RINOK(ReturnIfError(E_ABORT)); + RINOK(ReturnIfError(E_OUTOFMEMORY)); + RINOK(ReturnIfError(S_FALSE)); + for (i = 0; i < _coders.Size(); i++) { HRESULT result = _coders[i].Result; diff --git a/CPP/7zip/Archive/Common/CoderMixer2MT.h b/CPP/7zip/Archive/Common/CoderMixer2MT.h index 3cd3282b..505f1a88 100755 --- a/CPP/7zip/Archive/Common/CoderMixer2MT.h +++ b/CPP/7zip/Archive/Common/CoderMixer2MT.h @@ -51,6 +51,7 @@ class CCoderMixer2MT: void AddCoderCommon(); HRESULT Init(ISequentialInStream **inStreams, ISequentialOutStream **outStreams); + HRESULT ReturnIfError(HRESULT code); public: CObjectVector<CCoder2> _coders; MY_UNKNOWN_IMP diff --git a/CPP/7zip/Archive/Common/CoderMixerMT.cpp b/CPP/7zip/Archive/Common/CoderMixerMT.cpp index ad32896c..6319c5da 100755 --- a/CPP/7zip/Archive/Common/CoderMixerMT.cpp +++ b/CPP/7zip/Archive/Common/CoderMixerMT.cpp @@ -30,6 +30,14 @@ void CCoderMixerMT::ReInit() _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 */, @@ -67,18 +75,10 @@ STDMETHODIMP CCoderMixerMT::Code(ISequentialInStream *inStream, if (i != _progressCoderIndex) _coders[i].WaitFinish(); - for (i = 0; i < _coders.Size(); i++) - { - HRESULT result = _coders[i].Result; - if (result == E_ABORT) - return result; - } - for (i = 0; i < _coders.Size(); i++) - { - HRESULT result = _coders[i].Result; - if (result == S_FALSE) - return result; - } + RINOK(ReturnIfError(E_ABORT)); + RINOK(ReturnIfError(E_OUTOFMEMORY)); + RINOK(ReturnIfError(S_FALSE)); + for (i = 0; i < _coders.Size(); i++) { HRESULT result = _coders[i].Result; diff --git a/CPP/7zip/Archive/Common/CoderMixerMT.h b/CPP/7zip/Archive/Common/CoderMixerMT.h index 88b6e3e6..6fd1ba44 100755 --- a/CPP/7zip/Archive/Common/CoderMixerMT.h +++ b/CPP/7zip/Archive/Common/CoderMixerMT.h @@ -42,6 +42,7 @@ class CCoderMixerMT: CObjectVector<CStreamBinder> _streamBinders; int _progressCoderIndex; + HRESULT ReturnIfError(HRESULT code); public: CObjectVector<CCoder> _coders; MY_UNKNOWN_IMP diff --git a/CPP/7zip/Archive/Common/DummyOutStream.cpp b/CPP/7zip/Archive/Common/DummyOutStream.cpp index b1d49913..54bcfec1 100755 --- a/CPP/7zip/Archive/Common/DummyOutStream.cpp +++ b/CPP/7zip/Archive/Common/DummyOutStream.cpp @@ -4,17 +4,19 @@ #include "DummyOutStream.h" -void CDummyOutStream::Init(ISequentialOutStream *outStream) +STDMETHODIMP CDummyOutStream::Write(const void *data, UInt32 size, UInt32 *processedSize) { - m_Stream = outStream; -} - -STDMETHODIMP CDummyOutStream::Write(const void *data, - UInt32 size, UInt32 *processedSize) -{ - if(m_Stream) - return m_Stream->Write(data, size, processedSize); + UInt32 realProcessedSize; + HRESULT result; + if(!_stream) + { + realProcessedSize = size; + result = S_OK; + } + else + result = _stream->Write(data, size, &realProcessedSize); + _size += realProcessedSize; if(processedSize != NULL) - *processedSize = size; - return S_OK; + *processedSize = realProcessedSize; + return result; } diff --git a/CPP/7zip/Archive/Common/DummyOutStream.h b/CPP/7zip/Archive/Common/DummyOutStream.h index 51690787..d19b3111 100755 --- a/CPP/7zip/Archive/Common/DummyOutStream.h +++ b/CPP/7zip/Archive/Common/DummyOutStream.h @@ -10,14 +10,14 @@ class CDummyOutStream: public ISequentialOutStream, public CMyUnknownImp { + CMyComPtr<ISequentialOutStream> _stream; + UInt64 _size; public: + void SetStream(ISequentialOutStream *outStream) { _stream = outStream; } + void Init() { _size = 0; } MY_UNKNOWN_IMP - STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize); -private: - CMyComPtr<ISequentialOutStream> m_Stream; -public: - void Init(ISequentialOutStream *outStream); + UInt64 GetSize() const { return _size; } }; #endif |