1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/other-licenses/7zstub/src/7zip/Common/ProgressUtils.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,58 @@ 1.4 +// ProgressUtils.h 1.5 + 1.6 +#include "StdAfx.h" 1.7 + 1.8 +#include "ProgressUtils.h" 1.9 + 1.10 +void CLocalCompressProgressInfo::Init(ICompressProgressInfo *progress, 1.11 + const UInt64 *inStartValue, const UInt64 *outStartValue) 1.12 +{ 1.13 + _progress = progress; 1.14 + _inStartValueIsAssigned = (inStartValue != NULL); 1.15 + if (_inStartValueIsAssigned) 1.16 + _inStartValue = *inStartValue; 1.17 + _outStartValueIsAssigned = (outStartValue != NULL); 1.18 + if (_outStartValueIsAssigned) 1.19 + _outStartValue = *outStartValue; 1.20 +} 1.21 + 1.22 +STDMETHODIMP CLocalCompressProgressInfo::SetRatioInfo( 1.23 + const UInt64 *inSize, const UInt64 *outSize) 1.24 +{ 1.25 + UInt64 inSizeNew, outSizeNew; 1.26 + const UInt64 *inSizeNewPointer; 1.27 + const UInt64 *outSizeNewPointer; 1.28 + if (_inStartValueIsAssigned && inSize != NULL) 1.29 + { 1.30 + inSizeNew = _inStartValue + (*inSize); 1.31 + inSizeNewPointer = &inSizeNew; 1.32 + } 1.33 + else 1.34 + inSizeNewPointer = NULL; 1.35 + 1.36 + if (_outStartValueIsAssigned && outSize != NULL) 1.37 + { 1.38 + outSizeNew = _outStartValue + (*outSize); 1.39 + outSizeNewPointer = &outSizeNew; 1.40 + } 1.41 + else 1.42 + outSizeNewPointer = NULL; 1.43 + return _progress->SetRatioInfo(inSizeNewPointer, outSizeNewPointer); 1.44 +} 1.45 + 1.46 + 1.47 +/////////////////////////////////// 1.48 +// 1.49 + 1.50 +void CLocalProgress::Init(IProgress *progress, bool inSizeIsMain) 1.51 +{ 1.52 + _progress = progress; 1.53 + _inSizeIsMain = inSizeIsMain; 1.54 +} 1.55 + 1.56 +STDMETHODIMP CLocalProgress::SetRatioInfo( 1.57 + const UInt64 *inSize, const UInt64 *outSize) 1.58 +{ 1.59 + return _progress->SetCompleted(_inSizeIsMain ? inSize : outSize); 1.60 +} 1.61 +