Files
easy7zip/CPP/7zip/Common/ProgressUtils.cpp
Igor Pavlov 051769bbc5 4.53 beta
2016-05-28 00:15:54 +01:00

41 lines
945 B
C++
Executable File

// ProgressUtils.h
#include "StdAfx.h"
#include "ProgressUtils.h"
CLocalProgress::CLocalProgress()
{
ProgressOffset = InSize = OutSize = 0;
SendRatio = true;
}
void CLocalProgress::Init(IProgress *progress, bool inSizeIsMain)
{
_ratioProgress.Release();
_progress = progress;
_progress.QueryInterface(IID_ICompressProgressInfo, &_ratioProgress);
_inSizeIsMain = inSizeIsMain;
}
STDMETHODIMP CLocalProgress::SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize)
{
UInt64 inSizeNew = InSize, outSizeNew = OutSize;
if (inSize)
inSizeNew += (*inSize);
if (outSize)
outSizeNew += (*outSize);
if (SendRatio && _ratioProgress)
{
RINOK(_ratioProgress->SetRatioInfo(&inSizeNew, &outSizeNew));
}
inSizeNew += ProgressOffset;
outSizeNew += ProgressOffset;
return _progress->SetCompleted(_inSizeIsMain ? &inSizeNew : &outSizeNew);
}
HRESULT CLocalProgress::SetCur()
{
return SetRatioInfo(NULL, NULL);
}