From f2902217b38cf2e16e851ae84d61247f8e828180 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Mon, 25 Mar 2019 17:53:14 +0100 Subject: Update the 7z installer stub source to 18.05. Tag #1022 --- .../7zstub/src/7zip/Archive/Common/CoderMixer2.cpp | 121 ------- .../7zstub/src/7zip/Archive/Common/CoderMixer2.h | 168 ---------- .../src/7zip/Archive/Common/CoderMixer2MT.cpp | 359 --------------------- .../7zstub/src/7zip/Archive/Common/CoderMixer2MT.h | 121 ------- .../7zip/Archive/Common/CrossThreadProgress.cpp | 15 - .../src/7zip/Archive/Common/CrossThreadProgress.h | 31 -- .../7zstub/src/7zip/Archive/Common/FilterCoder.cpp | 242 -------------- .../7zstub/src/7zip/Archive/Common/FilterCoder.h | 130 -------- .../src/7zip/Archive/Common/ItemNameUtils.cpp | 59 ---- .../7zstub/src/7zip/Archive/Common/ItemNameUtils.h | 24 -- .../src/7zip/Archive/Common/OutStreamWithCRC.cpp | 23 -- .../src/7zip/Archive/Common/OutStreamWithCRC.h | 33 -- 12 files changed, 1326 deletions(-) delete mode 100644 other-licenses/7zstub/src/7zip/Archive/Common/CoderMixer2.cpp delete mode 100644 other-licenses/7zstub/src/7zip/Archive/Common/CoderMixer2.h delete mode 100644 other-licenses/7zstub/src/7zip/Archive/Common/CoderMixer2MT.cpp delete mode 100644 other-licenses/7zstub/src/7zip/Archive/Common/CoderMixer2MT.h delete mode 100644 other-licenses/7zstub/src/7zip/Archive/Common/CrossThreadProgress.cpp delete mode 100644 other-licenses/7zstub/src/7zip/Archive/Common/CrossThreadProgress.h delete mode 100644 other-licenses/7zstub/src/7zip/Archive/Common/FilterCoder.cpp delete mode 100644 other-licenses/7zstub/src/7zip/Archive/Common/FilterCoder.h delete mode 100644 other-licenses/7zstub/src/7zip/Archive/Common/ItemNameUtils.cpp delete mode 100644 other-licenses/7zstub/src/7zip/Archive/Common/ItemNameUtils.h delete mode 100644 other-licenses/7zstub/src/7zip/Archive/Common/OutStreamWithCRC.cpp delete mode 100644 other-licenses/7zstub/src/7zip/Archive/Common/OutStreamWithCRC.h (limited to 'other-licenses/7zstub/src/7zip/Archive/Common') diff --git a/other-licenses/7zstub/src/7zip/Archive/Common/CoderMixer2.cpp b/other-licenses/7zstub/src/7zip/Archive/Common/CoderMixer2.cpp deleted file mode 100644 index 4a552bf09..000000000 --- a/other-licenses/7zstub/src/7zip/Archive/Common/CoderMixer2.cpp +++ /dev/null @@ -1,121 +0,0 @@ -// CoderMixer2.cpp - -#include "StdAfx.h" - -#include "CoderMixer2.h" - -namespace NCoderMixer2 { - -CBindReverseConverter::CBindReverseConverter(const CBindInfo &srcBindInfo): - _srcBindInfo(srcBindInfo) -{ - srcBindInfo.GetNumStreams(NumSrcInStreams, _numSrcOutStreams); - - UInt32 j; - for (j = 0; j < NumSrcInStreams; j++) - { - _srcInToDestOutMap.Add(0); - DestOutToSrcInMap.Add(0); - } - for (j = 0; j < _numSrcOutStreams; j++) - { - _srcOutToDestInMap.Add(0); - _destInToSrcOutMap.Add(0); - } - - UInt32 destInOffset = 0; - UInt32 destOutOffset = 0; - UInt32 srcInOffset = NumSrcInStreams; - UInt32 srcOutOffset = _numSrcOutStreams; - - for (int i = srcBindInfo.Coders.Size() - 1; i >= 0; i--) - { - const CCoderStreamsInfo &srcCoderInfo = srcBindInfo.Coders[i]; - - srcInOffset -= srcCoderInfo.NumInStreams; - srcOutOffset -= srcCoderInfo.NumOutStreams; - - UInt32 j; - for (j = 0; j < srcCoderInfo.NumInStreams; j++, destOutOffset++) - { - UInt32 index = srcInOffset + j; - _srcInToDestOutMap[index] = destOutOffset; - DestOutToSrcInMap[destOutOffset] = index; - } - for (j = 0; j < srcCoderInfo.NumOutStreams; j++, destInOffset++) - { - UInt32 index = srcOutOffset + j; - _srcOutToDestInMap[index] = destInOffset; - _destInToSrcOutMap[destInOffset] = index; - } - } -} - -void CBindReverseConverter::CreateReverseBindInfo(CBindInfo &destBindInfo) -{ - destBindInfo.Coders.Clear(); - destBindInfo.BindPairs.Clear(); - destBindInfo.InStreams.Clear(); - destBindInfo.OutStreams.Clear(); - - int i; - for (i = _srcBindInfo.Coders.Size() - 1; i >= 0; i--) - { - const CCoderStreamsInfo &srcCoderInfo = _srcBindInfo.Coders[i]; - CCoderStreamsInfo destCoderInfo; - destCoderInfo.NumInStreams = srcCoderInfo.NumOutStreams; - destCoderInfo.NumOutStreams = srcCoderInfo.NumInStreams; - destBindInfo.Coders.Add(destCoderInfo); - } - for (i = _srcBindInfo.BindPairs.Size() - 1; i >= 0; i--) - { - const CBindPair &srcBindPair = _srcBindInfo.BindPairs[i]; - CBindPair destBindPair; - destBindPair.InIndex = _srcOutToDestInMap[srcBindPair.OutIndex]; - destBindPair.OutIndex = _srcInToDestOutMap[srcBindPair.InIndex]; - destBindInfo.BindPairs.Add(destBindPair); - } - for (i = 0; i < _srcBindInfo.InStreams.Size(); i++) - destBindInfo.OutStreams.Add(_srcInToDestOutMap[_srcBindInfo.InStreams[i]]); - for (i = 0; i < _srcBindInfo.OutStreams.Size(); i++) - destBindInfo.InStreams.Add(_srcOutToDestInMap[_srcBindInfo.OutStreams[i]]); -} - -CCoderInfo::CCoderInfo(UInt32 numInStreams, UInt32 numOutStreams): - NumInStreams(numInStreams), - NumOutStreams(numOutStreams) -{ - InSizes.Reserve(NumInStreams); - InSizePointers.Reserve(NumInStreams); - OutSizePointers.Reserve(NumOutStreams); - OutSizePointers.Reserve(NumOutStreams); -} - -static void SetSizes(const UInt64 **srcSizes, CRecordVector &sizes, - CRecordVector &sizePointers, UInt32 numItems) -{ - sizes.Clear(); - sizePointers.Clear(); - for(UInt32 i = 0; i < numItems; i++) - { - if (srcSizes == 0 || srcSizes[i] == NULL) - { - sizes.Add(0); - sizePointers.Add(NULL); - } - else - { - sizes.Add(*srcSizes[i]); - sizePointers.Add(&sizes.Back()); - } - } -} - -void CCoderInfo::SetCoderInfo(const UInt64 **inSizes, - const UInt64 **outSizes) -{ - SetSizes(inSizes, InSizes, InSizePointers, NumInStreams); - SetSizes(outSizes, OutSizes, OutSizePointers, NumOutStreams); -} - -} diff --git a/other-licenses/7zstub/src/7zip/Archive/Common/CoderMixer2.h b/other-licenses/7zstub/src/7zip/Archive/Common/CoderMixer2.h deleted file mode 100644 index 00cca2190..000000000 --- a/other-licenses/7zstub/src/7zip/Archive/Common/CoderMixer2.h +++ /dev/null @@ -1,168 +0,0 @@ -// CoderMixer2.h - -#ifndef __CODER_MIXER2_H -#define __CODER_MIXER2_H - -#include "../../../Common/Vector.h" -#include "../../../Common/Types.h" -#include "../../../Common/MyCom.h" -#include "../../ICoder.h" - -namespace NCoderMixer2 { - -struct CBindPair -{ - UInt32 InIndex; - UInt32 OutIndex; -}; - -struct CCoderStreamsInfo -{ - UInt32 NumInStreams; - UInt32 NumOutStreams; -}; - -struct CBindInfo -{ - CRecordVector Coders; - CRecordVector BindPairs; - CRecordVector InStreams; - CRecordVector OutStreams; - - void Clear() - { - Coders.Clear(); - BindPairs.Clear(); - InStreams.Clear(); - OutStreams.Clear(); - } - - /* - UInt32 GetCoderStartOutStream(UInt32 coderIndex) const - { - UInt32 numOutStreams = 0; - for (UInt32 i = 0; i < coderIndex; i++) - numOutStreams += Coders[i].NumOutStreams; - return numOutStreams; - } - */ - - - void GetNumStreams(UInt32 &numInStreams, UInt32 &numOutStreams) const - { - numInStreams = 0; - numOutStreams = 0; - for (int i = 0; i < Coders.Size(); i++) - { - const CCoderStreamsInfo &coderStreamsInfo = Coders[i]; - numInStreams += coderStreamsInfo.NumInStreams; - numOutStreams += coderStreamsInfo.NumOutStreams; - } - } - - int FindBinderForInStream(UInt32 inStream) const - { - for (int i = 0; i < BindPairs.Size(); i++) - if (BindPairs[i].InIndex == inStream) - return i; - return -1; - } - int FindBinderForOutStream(UInt32 outStream) const - { - for (int i = 0; i < BindPairs.Size(); i++) - if (BindPairs[i].OutIndex == outStream) - return i; - return -1; - } - - UInt32 GetCoderInStreamIndex(UInt32 coderIndex) const - { - UInt32 streamIndex = 0; - for (UInt32 i = 0; i < coderIndex; i++) - streamIndex += Coders[i].NumInStreams; - return streamIndex; - } - - UInt32 GetCoderOutStreamIndex(UInt32 coderIndex) const - { - UInt32 streamIndex = 0; - for (UInt32 i = 0; i < coderIndex; i++) - streamIndex += Coders[i].NumOutStreams; - return streamIndex; - } - - - void FindInStream(UInt32 streamIndex, UInt32 &coderIndex, - UInt32 &coderStreamIndex) const - { - for (coderIndex = 0; coderIndex < (UInt32)Coders.Size(); coderIndex++) - { - UInt32 curSize = Coders[coderIndex].NumInStreams; - if (streamIndex < curSize) - { - coderStreamIndex = streamIndex; - return; - } - streamIndex -= curSize; - } - throw 1; - } - void FindOutStream(UInt32 streamIndex, UInt32 &coderIndex, - UInt32 &coderStreamIndex) const - { - for (coderIndex = 0; coderIndex < (UInt32)Coders.Size(); coderIndex++) - { - UInt32 curSize = Coders[coderIndex].NumOutStreams; - if (streamIndex < curSize) - { - coderStreamIndex = streamIndex; - return; - } - streamIndex -= curSize; - } - throw 1; - } -}; - -class CBindReverseConverter -{ - UInt32 _numSrcOutStreams; - const NCoderMixer2::CBindInfo _srcBindInfo; - CRecordVector _srcInToDestOutMap; - CRecordVector _srcOutToDestInMap; - CRecordVector _destInToSrcOutMap; -public: - UInt32 NumSrcInStreams; - CRecordVector DestOutToSrcInMap; - - CBindReverseConverter(const NCoderMixer2::CBindInfo &srcBindInfo); - void CreateReverseBindInfo(NCoderMixer2::CBindInfo &destBindInfo); -}; - -struct CCoderInfo -{ - CMyComPtr Coder; - CMyComPtr Coder2; - UInt32 NumInStreams; - UInt32 NumOutStreams; - - CRecordVector InSizes; - CRecordVector OutSizes; - CRecordVector InSizePointers; - CRecordVector OutSizePointers; - - CCoderInfo(UInt32 numInStreams, UInt32 numOutStreams); - void SetCoderInfo(const UInt64 **inSizes, const UInt64 **outSizes); -}; - -class CCoderMixer2 -{ -public: - virtual void SetBindInfo(const CBindInfo &bindInfo) = 0; - virtual void ReInit() = 0; - virtual void SetCoderInfo(UInt32 coderIndex, const UInt64 **inSizes, const UInt64 **outSizes) = 0; -}; - -} -#endif - diff --git a/other-licenses/7zstub/src/7zip/Archive/Common/CoderMixer2MT.cpp b/other-licenses/7zstub/src/7zip/Archive/Common/CoderMixer2MT.cpp deleted file mode 100644 index 7b3ff7383..000000000 --- a/other-licenses/7zstub/src/7zip/Archive/Common/CoderMixer2MT.cpp +++ /dev/null @@ -1,359 +0,0 @@ -// CoderMixer2MT.cpp - -#include "StdAfx.h" - -#include "CoderMixer2MT.h" -#include "CrossThreadProgress.h" - -using namespace NWindows; -using namespace NSynchronization; - -namespace NCoderMixer2 { - -CThreadCoderInfo::CThreadCoderInfo(UInt32 numInStreams, UInt32 numOutStreams): - ExitEvent(NULL), - CompressEvent(NULL), - CompressionCompletedEvent(NULL), - CCoderInfo(numInStreams, numOutStreams) -{ - InStreams.Reserve(NumInStreams); - InStreamPointers.Reserve(NumInStreams); - OutStreams.Reserve(NumOutStreams); - OutStreamPointers.Reserve(NumOutStreams); -} - -void CThreadCoderInfo::CreateEvents() -{ - CompressEvent = new CAutoResetEvent(false); - CompressionCompletedEvent = new CAutoResetEvent(false); -} - -CThreadCoderInfo::~CThreadCoderInfo() -{ - if (CompressEvent != NULL) - delete CompressEvent; - if (CompressionCompletedEvent != NULL) - delete CompressionCompletedEvent; -} - -class CCoderInfoFlusher2 -{ - CThreadCoderInfo *m_CoderInfo; -public: - CCoderInfoFlusher2(CThreadCoderInfo *coderInfo): m_CoderInfo(coderInfo) {} - ~CCoderInfoFlusher2() - { - int i; - for (i = 0; i < m_CoderInfo->InStreams.Size(); i++) - m_CoderInfo->InStreams[i].Release(); - for (i = 0; i < m_CoderInfo->OutStreams.Size(); i++) - m_CoderInfo->OutStreams[i].Release(); - m_CoderInfo->CompressionCompletedEvent->Set(); - } -}; - -bool CThreadCoderInfo::WaitAndCode() -{ - HANDLE events[2] = { ExitEvent, *CompressEvent }; - DWORD waitResult = ::WaitForMultipleObjects(2, events, FALSE, INFINITE); - if (waitResult == WAIT_OBJECT_0 + 0) - return false; - - { - InStreamPointers.Clear(); - OutStreamPointers.Clear(); - UInt32 i; - for (i = 0; i < NumInStreams; i++) - { - if (InSizePointers[i] != NULL) - InSizePointers[i] = &InSizes[i]; - InStreamPointers.Add(InStreams[i]); - } - for (i = 0; i < NumOutStreams; i++) - { - if (OutSizePointers[i] != NULL) - OutSizePointers[i] = &OutSizes[i]; - OutStreamPointers.Add(OutStreams[i]); - } - CCoderInfoFlusher2 coderInfoFlusher(this); - if (Coder) - Result = Coder->Code(InStreamPointers[0], - OutStreamPointers[0], - InSizePointers[0], - OutSizePointers[0], - Progress); - else - Result = Coder2->Code(&InStreamPointers.Front(), - &InSizePointers.Front(), - NumInStreams, - &OutStreamPointers.Front(), - &OutSizePointers.Front(), - NumOutStreams, - Progress); - } - return true; -} - -static void SetSizes(const UInt64 **srcSizes, CRecordVector &sizes, - CRecordVector &sizePointers, UInt32 numItems) -{ - sizes.Clear(); - sizePointers.Clear(); - for(UInt32 i = 0; i < numItems; i++) - { - if (srcSizes == 0 || srcSizes[i] == NULL) - { - sizes.Add(0); - sizePointers.Add(NULL); - } - else - { - sizes.Add(*srcSizes[i]); - sizePointers.Add(&sizes.Back()); - } - } -} - - -void CThreadCoderInfo::SetCoderInfo(const UInt64 **inSizes, - const UInt64 **outSizes, ICompressProgressInfo *progress) -{ - Progress = progress; - SetSizes(inSizes, InSizes, InSizePointers, NumInStreams); - SetSizes(outSizes, OutSizes, OutSizePointers, NumOutStreams); -} - -static DWORD WINAPI CoderThread(void *threadCoderInfo) -{ - while(true) - { - if (!((CThreadCoderInfo *)threadCoderInfo)->WaitAndCode()) - return 0; - } -} - -////////////////////////////////////// -// CCoderMixer2MT - -static DWORD WINAPI MainCoderThread(void *threadCoderInfo) -{ - while(true) - { - if (!((CCoderMixer2MT *)threadCoderInfo)->MyCode()) - return 0; - } -} - -CCoderMixer2MT::CCoderMixer2MT() -{ - if (!_mainThread.Create(MainCoderThread, this)) - throw 271825; -} - -CCoderMixer2MT::~CCoderMixer2MT() -{ - _exitEvent.Set(); - _mainThread.Wait(); - for(int i = 0; i < _threads.Size(); i++) - { - _threads[i].Wait(); - _threads[i].Close(); - } -} - -void CCoderMixer2MT::SetBindInfo(const CBindInfo &bindInfo) -{ - _bindInfo = bindInfo; - _streamBinders.Clear(); - for(int i = 0; i < _bindInfo.BindPairs.Size(); i++) - { - _streamBinders.Add(CStreamBinder()); - _streamBinders.Back().CreateEvents(); - } -} - -void CCoderMixer2MT::AddCoderCommon() -{ - int index = _coderInfoVector.Size(); - const CCoderStreamsInfo &CoderStreamsInfo = _bindInfo.Coders[index]; - - CThreadCoderInfo threadCoderInfo(CoderStreamsInfo.NumInStreams, - CoderStreamsInfo.NumOutStreams); - _coderInfoVector.Add(threadCoderInfo); - _coderInfoVector.Back().CreateEvents(); - _coderInfoVector.Back().ExitEvent = _exitEvent; - _compressingCompletedEvents.Add(*_coderInfoVector.Back().CompressionCompletedEvent); - - NWindows::CThread newThread; - _threads.Add(newThread); - if (!_threads.Back().Create(CoderThread, &_coderInfoVector.Back())) - throw 271824; -} - -void CCoderMixer2MT::AddCoder(ICompressCoder *coder) -{ - AddCoderCommon(); - _coderInfoVector.Back().Coder = coder; -} - -void CCoderMixer2MT::AddCoder2(ICompressCoder2 *coder) -{ - AddCoderCommon(); - _coderInfoVector.Back().Coder2 = coder; -} - -/* -void CCoderMixer2MT::FinishAddingCoders() -{ - for(int i = 0; i < _coderInfoVector.Size(); i++) - { - DWORD id; - HANDLE newThread = ::CreateThread(NULL, 0, CoderThread, - &_coderInfoVector[i], 0, &id); - if (newThread == 0) - throw 271824; - _threads.Add(newThread); - } -} -*/ - -void CCoderMixer2MT::ReInit() -{ - for(int i = 0; i < _streamBinders.Size(); i++) - _streamBinders[i].ReInit(); -} - - -STDMETHODIMP CCoderMixer2MT::Init(ISequentialInStream **inStreams, - ISequentialOutStream **outStreams) -{ - if (_coderInfoVector.Size() != _bindInfo.Coders.Size()) - throw 0; - int i; - for(i = 0; i < _coderInfoVector.Size(); i++) - { - CThreadCoderInfo &coderInfo = _coderInfoVector[i]; - const CCoderStreamsInfo &coderStreamsInfo = _bindInfo.Coders[i]; - coderInfo.InStreams.Clear(); - UInt32 j; - for(j = 0; j < coderStreamsInfo.NumInStreams; j++) - coderInfo.InStreams.Add(NULL); - coderInfo.OutStreams.Clear(); - for(j = 0; j < coderStreamsInfo.NumOutStreams; j++) - coderInfo.OutStreams.Add(NULL); - } - - for(i = 0; i < _bindInfo.BindPairs.Size(); i++) - { - const CBindPair &bindPair = _bindInfo.BindPairs[i]; - UInt32 inCoderIndex, inCoderStreamIndex; - UInt32 outCoderIndex, outCoderStreamIndex; - _bindInfo.FindInStream(bindPair.InIndex, inCoderIndex, inCoderStreamIndex); - _bindInfo.FindOutStream(bindPair.OutIndex, outCoderIndex, outCoderStreamIndex); - - _streamBinders[i].CreateStreams( - &_coderInfoVector[inCoderIndex].InStreams[inCoderStreamIndex], - &_coderInfoVector[outCoderIndex].OutStreams[outCoderStreamIndex]); - } - - for(i = 0; i < _bindInfo.InStreams.Size(); i++) - { - UInt32 inCoderIndex, inCoderStreamIndex; - _bindInfo.FindInStream(_bindInfo.InStreams[i], inCoderIndex, inCoderStreamIndex); - _coderInfoVector[inCoderIndex].InStreams[inCoderStreamIndex] = inStreams[i]; - } - - for(i = 0; i < _bindInfo.OutStreams.Size(); i++) - { - UInt32 outCoderIndex, outCoderStreamIndex; - _bindInfo.FindOutStream(_bindInfo.OutStreams[i], outCoderIndex, outCoderStreamIndex); - _coderInfoVector[outCoderIndex].OutStreams[outCoderStreamIndex] = outStreams[i]; - } - return S_OK; -} - - -bool CCoderMixer2MT::MyCode() -{ - HANDLE events[2] = { _exitEvent, _startCompressingEvent }; - DWORD waitResult = ::WaitForMultipleObjects(2, events, FALSE, INFINITE); - if (waitResult == WAIT_OBJECT_0 + 0) - return false; - - for(int i = 0; i < _coderInfoVector.Size(); i++) - _coderInfoVector[i].CompressEvent->Set(); - DWORD result = ::WaitForMultipleObjects(_compressingCompletedEvents.Size(), - &_compressingCompletedEvents.Front(), TRUE, INFINITE); - - _compressingFinishedEvent.Set(); - - return true; -} - - -STDMETHODIMP CCoderMixer2MT::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; - - Init(inStreams, outStreams); - - _compressingFinishedEvent.Reset(); // ? - - CCrossThreadProgress *progressSpec = new CCrossThreadProgress; - CMyComPtr crossProgress = progressSpec; - progressSpec->Init(); - _coderInfoVector[_progressCoderIndex].Progress = crossProgress; - - _startCompressingEvent.Set(); - - - while (true) - { - HANDLE events[2] = {_compressingFinishedEvent, progressSpec->ProgressEvent }; - DWORD waitResult = ::WaitForMultipleObjects(2, events, FALSE, INFINITE); - if (waitResult == WAIT_OBJECT_0 + 0) - break; - if (progress != NULL) - progressSpec->Result = progress->SetRatioInfo(progressSpec->InSize, - progressSpec->OutSize); - else - progressSpec->Result = S_OK; - progressSpec->WaitEvent.Set(); - } - - int i; - for(i = 0; i < _coderInfoVector.Size(); i++) - { - HRESULT result = _coderInfoVector[i].Result; - if (result == S_FALSE) - return result; - } - for(i = 0; i < _coderInfoVector.Size(); i++) - { - HRESULT result = _coderInfoVector[i].Result; - if (result != S_OK && result != E_FAIL) - return result; - } - for(i = 0; i < _coderInfoVector.Size(); i++) - { - HRESULT result = _coderInfoVector[i].Result; - if (result != S_OK) - return result; - } - return S_OK; -} - -UInt64 CCoderMixer2MT::GetWriteProcessedSize(UInt32 binderIndex) const -{ - return _streamBinders[binderIndex].ProcessedSize; -} - -} diff --git a/other-licenses/7zstub/src/7zip/Archive/Common/CoderMixer2MT.h b/other-licenses/7zstub/src/7zip/Archive/Common/CoderMixer2MT.h deleted file mode 100644 index 9a7221965..000000000 --- a/other-licenses/7zstub/src/7zip/Archive/Common/CoderMixer2MT.h +++ /dev/null @@ -1,121 +0,0 @@ -// CoderMixer2MT.h - -#ifndef __CODER_MIXER2_MT_H -#define __CODER_MIXER2_MT_H - -#include "CoderMixer2.h" -#include "../../../Common/MyCom.h" -#include "../../../Windows/Thread.h" -#include "../../Common/StreamBinder.h" - -namespace NCoderMixer2 { - -// CreateEvents(); -// { -// SetCoderInfo() -// Init Streams -// set CompressEvent() -// wait CompressionCompletedEvent -// } - -struct CThreadCoderInfo: public CCoderInfo -{ - NWindows::NSynchronization::CAutoResetEvent *CompressEvent; - HANDLE ExitEvent; - NWindows::NSynchronization::CAutoResetEvent *CompressionCompletedEvent; - - CObjectVector< CMyComPtr > InStreams; - CObjectVector< CMyComPtr > OutStreams; - CRecordVector InStreamPointers; - CRecordVector OutStreamPointers; - - CMyComPtr Progress; // CMyComPtr - HRESULT Result; - - CThreadCoderInfo(UInt32 numInStreams, UInt32 numOutStreams); - void SetCoderInfo(const UInt64 **inSizes, - const UInt64 **outSizes, ICompressProgressInfo *progress); - ~CThreadCoderInfo(); - bool WaitAndCode(); - void CreateEvents(); -}; - - -// SetBindInfo() -// for each coder -// { -// AddCoder[2]() -// } -// -// for each file -// { -// ReInit() -// for each coder -// { -// SetCoderInfo -// } -// SetProgressIndex(UInt32 coderIndex); -// Code -// } - - -class CCoderMixer2MT: - public ICompressCoder2, - public CCoderMixer2, - public CMyUnknownImp -{ - MY_UNKNOWN_IMP - -public: - STDMETHOD(Init)(ISequentialInStream **inStreams, - ISequentialOutStream **outStreams); - - STDMETHOD(Code)(ISequentialInStream **inStreams, - const UInt64 **inSizes, - UInt32 numInStreams, - ISequentialOutStream **outStreams, - const UInt64 **outSizes, - UInt32 numOutStreams, - ICompressProgressInfo *progress); - - - CCoderMixer2MT(); - ~CCoderMixer2MT(); - void AddCoderCommon(); - void AddCoder(ICompressCoder *coder); - void AddCoder2(ICompressCoder2 *coder); - - void ReInit(); - void SetCoderInfo(UInt32 coderIndex, const UInt64 **inSizes, const UInt64 **outSizes) - { _coderInfoVector[coderIndex].SetCoderInfo(inSizes, outSizes, NULL); } - void SetProgressCoderIndex(UInt32 coderIndex) - { _progressCoderIndex = coderIndex; } - - - UInt64 GetWriteProcessedSize(UInt32 binderIndex) const; - - - bool MyCode(); - -private: - CBindInfo _bindInfo; - CObjectVector _streamBinders; - CObjectVector _coderInfoVector; - CRecordVector _threads; - NWindows::CThread _mainThread; - - NWindows::NSynchronization::CAutoResetEvent _startCompressingEvent; - CRecordVector _compressingCompletedEvents; - NWindows::NSynchronization::CAutoResetEvent _compressingFinishedEvent; - - NWindows::NSynchronization::CManualResetEvent _exitEvent; - UInt32 _progressCoderIndex; - -public: - void SetBindInfo(const CBindInfo &bindInfo); - -}; - -} -#endif - diff --git a/other-licenses/7zstub/src/7zip/Archive/Common/CrossThreadProgress.cpp b/other-licenses/7zstub/src/7zip/Archive/Common/CrossThreadProgress.cpp deleted file mode 100644 index 62d05afdd..000000000 --- a/other-licenses/7zstub/src/7zip/Archive/Common/CrossThreadProgress.cpp +++ /dev/null @@ -1,15 +0,0 @@ -// CrossThreadProgress.cpp - -#include "StdAfx.h" - -#include "CrossThreadProgress.h" - -STDMETHODIMP CCrossThreadProgress::SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize) -{ - InSize = inSize; - OutSize = outSize; - ProgressEvent.Set(); - WaitEvent.Lock(); - return Result; -} - diff --git a/other-licenses/7zstub/src/7zip/Archive/Common/CrossThreadProgress.h b/other-licenses/7zstub/src/7zip/Archive/Common/CrossThreadProgress.h deleted file mode 100644 index 0504b9306..000000000 --- a/other-licenses/7zstub/src/7zip/Archive/Common/CrossThreadProgress.h +++ /dev/null @@ -1,31 +0,0 @@ -// CrossThreadProgress.h - -#ifndef __CROSSTHREADPROGRESS_H -#define __CROSSTHREADPROGRESS_H - -#include "../../ICoder.h" -#include "../../../Windows/Synchronization.h" -#include "../../../Common/MyCom.h" - -class CCrossThreadProgress: - public ICompressProgressInfo, - public CMyUnknownImp -{ -public: - const UInt64 *InSize; - const UInt64 *OutSize; - HRESULT Result; - NWindows::NSynchronization::CAutoResetEvent ProgressEvent; - NWindows::NSynchronization::CAutoResetEvent WaitEvent; - void Init() - { - ProgressEvent.Reset(); - WaitEvent.Reset(); - } - - MY_UNKNOWN_IMP - - STDMETHOD(SetRatioInfo)(const UInt64 *inSize, const UInt64 *outSize); -}; - -#endif diff --git a/other-licenses/7zstub/src/7zip/Archive/Common/FilterCoder.cpp b/other-licenses/7zstub/src/7zip/Archive/Common/FilterCoder.cpp deleted file mode 100644 index fa8aba2e4..000000000 --- a/other-licenses/7zstub/src/7zip/Archive/Common/FilterCoder.cpp +++ /dev/null @@ -1,242 +0,0 @@ -// FilterCoder.cpp - -#include "StdAfx.h" - -#include "FilterCoder.h" -#include "../../../Common/Alloc.h" -#include "../../../Common/Defs.h" -#include "../../Common/StreamUtils.h" - -static const int kBufferSize = 1 << 17; - -CFilterCoder::CFilterCoder() -{ - _buffer = (Byte *)::MidAlloc(kBufferSize); -} - -CFilterCoder::~CFilterCoder() -{ - ::MidFree(_buffer); -} - -HRESULT CFilterCoder::WriteWithLimit(ISequentialOutStream *outStream, UInt32 size) -{ - if (_outSizeIsDefined) - { - UInt64 remSize = _outSize - _nowPos64; - if (size > remSize) - size = (UInt32)remSize; - } - UInt32 processedSize = 0; - RINOK(WriteStream(outStream, _buffer, size, &processedSize)); - if (size != processedSize) - return E_FAIL; - _nowPos64 += processedSize; - return S_OK; -} - - -STDMETHODIMP CFilterCoder::Code(ISequentialInStream *inStream, - ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize, - ICompressProgressInfo *progress) -{ - RINOK(Init()); - UInt32 bufferPos = 0; - if (_outSizeIsDefined = (outSize != 0)) - _outSize = *outSize; - - while(NeedMore()) - { - UInt32 processedSize; - - // Change it: It can be optimized using ReadPart - RINOK(ReadStream(inStream, _buffer + bufferPos, kBufferSize - bufferPos, &processedSize)); - - UInt32 endPos = bufferPos + processedSize; - - bufferPos = Filter->Filter(_buffer, endPos); - if (bufferPos > endPos) - { - for (; endPos< bufferPos; endPos++) - _buffer[endPos] = 0; - bufferPos = Filter->Filter(_buffer, endPos); - } - - if (bufferPos == 0) - { - if (endPos > 0) - return WriteWithLimit(outStream, endPos); - return S_OK; - } - RINOK(WriteWithLimit(outStream, bufferPos)); - if (progress != NULL) - { - RINOK(progress->SetRatioInfo(&_nowPos64, &_nowPos64)); - } - UInt32 i = 0; - while(bufferPos < endPos) - _buffer[i++] = _buffer[bufferPos++]; - bufferPos = i; - } - return S_OK; -} - -// #ifdef _ST_MODE -STDMETHODIMP CFilterCoder::SetOutStream(ISequentialOutStream *outStream) -{ - _bufferPos = 0; - _outStream = outStream; - return Init(); -} - -STDMETHODIMP CFilterCoder::ReleaseOutStream() -{ - _outStream.Release(); - return S_OK; -}; - - -STDMETHODIMP CFilterCoder::Write(const void *data, UInt32 size, UInt32 *processedSize) -{ - UInt32 processedSizeTotal = 0; - while(size > 0) - { - UInt32 sizeMax = kBufferSize - _bufferPos; - UInt32 sizeTemp = size; - if (sizeTemp > sizeMax) - sizeTemp = sizeMax; - memmove(_buffer + _bufferPos, data, sizeTemp); - size -= sizeTemp; - processedSizeTotal += sizeTemp; - data = (const Byte *)data + sizeTemp; - UInt32 endPos = _bufferPos + sizeTemp; - _bufferPos = Filter->Filter(_buffer, endPos); - if (_bufferPos == 0) - { - _bufferPos = endPos; - break; - } - if (_bufferPos > endPos) - { - if (size != 0) - return E_FAIL; - break; - } - RINOK(WriteWithLimit(_outStream, _bufferPos)); - UInt32 i = 0; - while(_bufferPos < endPos) - _buffer[i++] = _buffer[_bufferPos++]; - _bufferPos = i; - } - if (processedSize != NULL) - *processedSize = processedSizeTotal; - return S_OK; -} - -STDMETHODIMP CFilterCoder::Flush() -{ - if (_bufferPos != 0) - { - UInt32 endPos = Filter->Filter(_buffer, _bufferPos); - if (endPos > _bufferPos) - { - for (; _bufferPos < endPos; _bufferPos++) - _buffer[_bufferPos] = 0; - if (Filter->Filter(_buffer, endPos) != endPos) - return E_FAIL; - } - UInt32 processedSize; - RINOK(WriteStream(_outStream, _buffer, _bufferPos, &processedSize)); - if (_bufferPos != processedSize) - return E_FAIL; - _bufferPos = 0; - } - CMyComPtr flush; - _outStream.QueryInterface(IID_IOutStreamFlush, &flush); - if (flush) - return flush->Flush(); - return S_OK; -} - - -STDMETHODIMP CFilterCoder::SetInStream(ISequentialInStream *inStream) -{ - _convertedPosBegin = _convertedPosEnd = _bufferPos = 0; - _inStream = inStream; - return Init(); -} - -STDMETHODIMP CFilterCoder::ReleaseInStream() -{ - _inStream.Release(); - return S_OK; -}; - -STDMETHODIMP CFilterCoder::Read(void *data, UInt32 size, UInt32 *processedSize) -{ - UInt32 processedSizeTotal = 0; - while(size > 0) - { - if (_convertedPosBegin != _convertedPosEnd) - { - UInt32 sizeTemp = MyMin(size, _convertedPosEnd - _convertedPosBegin); - memmove(data, _buffer + _convertedPosBegin, sizeTemp); - _convertedPosBegin += sizeTemp; - data = (void *)((Byte *)data + sizeTemp); - size -= sizeTemp; - processedSizeTotal += sizeTemp; - break; - } - int i; - for (i = 0; _convertedPosEnd + i < _bufferPos; i++) - _buffer[i] = _buffer[i + _convertedPosEnd]; - _bufferPos = i; - _convertedPosBegin = _convertedPosEnd = 0; - UInt32 processedSizeTemp; - UInt32 size0 = kBufferSize - _bufferPos; - // Optimize it: - RINOK(ReadStream(_inStream, _buffer + _bufferPos, size0, &processedSizeTemp)); - _bufferPos = _bufferPos + processedSizeTemp; - _convertedPosEnd = Filter->Filter(_buffer, _bufferPos); - if (_convertedPosEnd == 0) - { - if (_bufferPos == 0) - break; - else - { - _convertedPosEnd = _bufferPos; // check it - continue; - } - } - if (_convertedPosEnd > _bufferPos) - { - for (; _bufferPos < _convertedPosEnd; _bufferPos++) - _buffer[_bufferPos] = 0; - _convertedPosEnd = Filter->Filter(_buffer, _bufferPos); - } - } - if (processedSize != NULL) - *processedSize = processedSizeTotal; - return S_OK; -} - -// #endif // _ST_MODE - -#ifndef _NO_CRYPTO -STDMETHODIMP CFilterCoder::CryptoSetPassword(const Byte *data, UInt32 size) -{ - return _setPassword->CryptoSetPassword(data, size); -} -#endif - -#ifndef EXTRACT_ONLY -STDMETHODIMP CFilterCoder::WriteCoderProperties(ISequentialOutStream *outStream) -{ - return _writeCoderProperties->WriteCoderProperties(outStream); -} -#endif - -STDMETHODIMP CFilterCoder::SetDecoderProperties2(const Byte *data, UInt32 size) -{ - return _setDecoderProperties->SetDecoderProperties2(data, size); -} diff --git a/other-licenses/7zstub/src/7zip/Archive/Common/FilterCoder.h b/other-licenses/7zstub/src/7zip/Archive/Common/FilterCoder.h deleted file mode 100644 index cf0033ab6..000000000 --- a/other-licenses/7zstub/src/7zip/Archive/Common/FilterCoder.h +++ /dev/null @@ -1,130 +0,0 @@ -// FilterCoder.h - -#ifndef __FILTERCODER_H -#define __FILTERCODER_H - -#include "../../../Common/MyCom.h" -#include "../../ICoder.h" -#include "../../IPassword.h" - -#define MY_QUERYINTERFACE_ENTRY_AG(i, sub0, sub) if (iid == IID_ ## i) \ -{ if (!sub) RINOK(sub0->QueryInterface(IID_ ## i, (void **)&sub)) \ -*outObject = (void *)(i *)this; AddRef(); return S_OK; } - -class CFilterCoder: - public ICompressCoder, - // #ifdef _ST_MODE - public ICompressSetInStream, - public ISequentialInStream, - public ICompressSetOutStream, - public ISequentialOutStream, - public IOutStreamFlush, - // #endif - - #ifndef _NO_CRYPTO - public ICryptoSetPassword, - #endif - #ifndef EXTRACT_ONLY - public ICompressWriteCoderProperties, - #endif - public ICompressSetDecoderProperties2, - public CMyUnknownImp -{ -protected: - Byte *_buffer; - // #ifdef _ST_MODE - CMyComPtr _inStream; - CMyComPtr _outStream; - UInt32 _bufferPos; - UInt32 _convertedPosBegin; - UInt32 _convertedPosEnd; - // #endif - bool _outSizeIsDefined; - UInt64 _outSize; - UInt64 _nowPos64; - - HRESULT Init() - { - _nowPos64 = 0; - _outSizeIsDefined = false; - return Filter->Init(); - } - - CMyComPtr _setPassword; - #ifndef EXTRACT_ONLY - CMyComPtr _writeCoderProperties; - #endif - CMyComPtr _setDecoderProperties; -public: - CMyComPtr Filter; - - CFilterCoder(); - ~CFilterCoder(); - HRESULT WriteWithLimit(ISequentialOutStream *outStream, UInt32 size); - bool NeedMore() const - { return (!_outSizeIsDefined || (_nowPos64 < _outSize)); } - -public: - MY_QUERYINTERFACE_BEGIN - MY_QUERYINTERFACE_ENTRY(ICompressCoder) - // #ifdef _ST_MODE - MY_QUERYINTERFACE_ENTRY(ICompressSetInStream) - MY_QUERYINTERFACE_ENTRY(ISequentialInStream) - - MY_QUERYINTERFACE_ENTRY(ICompressSetOutStream) - MY_QUERYINTERFACE_ENTRY(ISequentialOutStream) - MY_QUERYINTERFACE_ENTRY(IOutStreamFlush) - // #endif - - #ifndef _NO_CRYPTO - MY_QUERYINTERFACE_ENTRY_AG(ICryptoSetPassword, Filter, _setPassword) - #endif - - #ifndef EXTRACT_ONLY - MY_QUERYINTERFACE_ENTRY_AG(ICompressWriteCoderProperties, Filter, _writeCoderProperties) - #endif - - MY_QUERYINTERFACE_ENTRY_AG(ICompressSetDecoderProperties2, Filter, _setDecoderProperties) - MY_QUERYINTERFACE_END - MY_ADDREF_RELEASE - STDMETHOD(Code)(ISequentialInStream *inStream, - ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize, - ICompressProgressInfo *progress); - // #ifdef _ST_MODE - STDMETHOD(ReleaseInStream)(); - STDMETHOD(SetInStream)(ISequentialInStream *inStream); - STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize); \ - STDMETHOD(SetOutStream)(ISequentialOutStream *outStream); - STDMETHOD(ReleaseOutStream)(); - STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize); - STDMETHOD(Flush)(); - // #endif - - #ifndef _NO_CRYPTO - STDMETHOD(CryptoSetPassword)(const Byte *data, UInt32 size); - #endif - #ifndef EXTRACT_ONLY - STDMETHOD(WriteCoderProperties)(ISequentialOutStream *outStream); - #endif - STDMETHOD(SetDecoderProperties2)(const Byte *data, UInt32 size); -}; - -// #ifdef _ST_MODE -class CInStreamReleaser -{ -public: - CFilterCoder *FilterCoder; - CInStreamReleaser(): FilterCoder(0) {} - ~CInStreamReleaser() { if (FilterCoder) FilterCoder->ReleaseInStream(); } -}; - -class COutStreamReleaser -{ -public: - CFilterCoder *FilterCoder; - COutStreamReleaser(): FilterCoder(0) {} - ~COutStreamReleaser() { if (FilterCoder) FilterCoder->ReleaseOutStream(); } -}; -// #endif - -#endif diff --git a/other-licenses/7zstub/src/7zip/Archive/Common/ItemNameUtils.cpp b/other-licenses/7zstub/src/7zip/Archive/Common/ItemNameUtils.cpp deleted file mode 100644 index 46f2cee3e..000000000 --- a/other-licenses/7zstub/src/7zip/Archive/Common/ItemNameUtils.cpp +++ /dev/null @@ -1,59 +0,0 @@ -// Archive/Common/ItemNameUtils.cpp - -#include "StdAfx.h" - -#include "ItemNameUtils.h" - -namespace NArchive { -namespace NItemName { - -static const wchar_t kOSDirDelimiter = WCHAR_PATH_SEPARATOR; -static const wchar_t kDirDelimiter = L'/'; - -UString MakeLegalName(const UString &name) -{ - UString zipName = name; - zipName.Replace(kOSDirDelimiter, kDirDelimiter); - return zipName; -} - -UString GetOSName(const UString &name) -{ - UString newName = name; - newName.Replace(kDirDelimiter, kOSDirDelimiter); - return newName; -} - -UString GetOSName2(const UString &name) -{ - if (name.IsEmpty()) - return UString(); - UString newName = GetOSName(name); - if (newName[newName.Length() - 1] == kOSDirDelimiter) - newName.Delete(newName.Length() - 1); - return newName; -} - -bool HasTailSlash(const AString &name, UINT codePage) -{ - if (name.IsEmpty()) - return false; - LPCSTR prev = - #ifdef _WIN32 - CharPrevExA(codePage, name, &name[name.Length()], 0); - #else - (LPCSTR)(name) + (name.Length() - 1); - #endif - return (*prev == '/'); -} - -#ifndef _WIN32 -UString WinNameToOSName(const UString &name) -{ - UString newName = name; - newName.Replace(L'\\', kOSDirDelimiter); - return newName; -} -#endif - -}} diff --git a/other-licenses/7zstub/src/7zip/Archive/Common/ItemNameUtils.h b/other-licenses/7zstub/src/7zip/Archive/Common/ItemNameUtils.h deleted file mode 100644 index 51e5d93f0..000000000 --- a/other-licenses/7zstub/src/7zip/Archive/Common/ItemNameUtils.h +++ /dev/null @@ -1,24 +0,0 @@ -// Archive/Common/ItemNameUtils.h - -#ifndef __ARCHIVE_ITEMNAMEUTILS_H -#define __ARCHIVE_ITEMNAMEUTILS_H - -#include "../../../Common/String.h" - -namespace NArchive { -namespace NItemName { - - UString MakeLegalName(const UString &name); - UString GetOSName(const UString &name); - UString GetOSName2(const 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 - -}} - -#endif diff --git a/other-licenses/7zstub/src/7zip/Archive/Common/OutStreamWithCRC.cpp b/other-licenses/7zstub/src/7zip/Archive/Common/OutStreamWithCRC.cpp deleted file mode 100644 index 6199562ee..000000000 --- a/other-licenses/7zstub/src/7zip/Archive/Common/OutStreamWithCRC.cpp +++ /dev/null @@ -1,23 +0,0 @@ -// OutStreamWithCRC.cpp - -#include "StdAfx.h" - -#include "OutStreamWithCRC.h" - -STDMETHODIMP COutStreamWithCRC::Write(const void *data, - UInt32 size, UInt32 *processedSize) -{ - UInt32 realProcessedSize; - HRESULT result; - if(!_stream) - { - realProcessedSize = size; - result = S_OK; - } - else - result = _stream->Write(data, size, &realProcessedSize); - _crc.Update(data, realProcessedSize); - if(processedSize != NULL) - *processedSize = realProcessedSize; - return result; -} diff --git a/other-licenses/7zstub/src/7zip/Archive/Common/OutStreamWithCRC.h b/other-licenses/7zstub/src/7zip/Archive/Common/OutStreamWithCRC.h deleted file mode 100644 index 11c5c579b..000000000 --- a/other-licenses/7zstub/src/7zip/Archive/Common/OutStreamWithCRC.h +++ /dev/null @@ -1,33 +0,0 @@ -// OutStreamWithCRC.h - -#ifndef __OUTSTREAMWITHCRC_H -#define __OUTSTREAMWITHCRC_H - -#include "../../../Common/CRC.h" -#include "../../../Common/MyCom.h" -#include "../../IStream.h" - -class COutStreamWithCRC: - public ISequentialOutStream, - public CMyUnknownImp -{ -public: - MY_UNKNOWN_IMP - - STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize); -private: - CCRC _crc; - CMyComPtr _stream; -public: - void Init(ISequentialOutStream *stream) - { - _stream = stream; - _crc.Init(); - } - void ReleaseStream() { _stream.Release(); } - UInt32 GetCRC() const { return _crc.GetDigest(); } - void InitCRC() { _crc.Init(); } - -}; - -#endif -- cgit v1.2.3