diff src/win32/7zip/7z/CPP/7zip/Common/ProgressUtils.cpp @ 1:f9f4f1b99eed

importing src directory
author Robert McIntyre <rlm@mit.edu>
date Sat, 03 Mar 2012 10:31:27 -0600
parents
children
line wrap: on
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/win32/7zip/7z/CPP/7zip/Common/ProgressUtils.cpp	Sat Mar 03 10:31:27 2012 -0600
     1.3 @@ -0,0 +1,42 @@
     1.4 +// ProgressUtils.h
     1.5 +
     1.6 +#include "StdAfx.h"
     1.7 +
     1.8 +#include "ProgressUtils.h"
     1.9 +
    1.10 +CLocalProgress::CLocalProgress()
    1.11 +{
    1.12 +  ProgressOffset = InSize = OutSize = 0;
    1.13 +  SendRatio = SendProgress = true;
    1.14 +}
    1.15 +
    1.16 +void CLocalProgress::Init(IProgress *progress, bool inSizeIsMain)
    1.17 +{
    1.18 +  _ratioProgress.Release();
    1.19 +  _progress = progress;
    1.20 +  _progress.QueryInterface(IID_ICompressProgressInfo, &_ratioProgress);
    1.21 +  _inSizeIsMain = inSizeIsMain;
    1.22 +}
    1.23 +
    1.24 +STDMETHODIMP CLocalProgress::SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize)
    1.25 +{
    1.26 +  UInt64 inSizeNew = InSize, outSizeNew = OutSize;
    1.27 +  if (inSize)
    1.28 +    inSizeNew += (*inSize);
    1.29 +  if (outSize)
    1.30 +    outSizeNew += (*outSize);
    1.31 +  if (SendRatio && _ratioProgress)
    1.32 +  {
    1.33 +    RINOK(_ratioProgress->SetRatioInfo(&inSizeNew, &outSizeNew));
    1.34 +  }
    1.35 +  inSizeNew += ProgressOffset;
    1.36 +  outSizeNew += ProgressOffset;
    1.37 +  if (SendProgress)
    1.38 +    return _progress->SetCompleted(_inSizeIsMain ? &inSizeNew : &outSizeNew);
    1.39 +  return S_OK;
    1.40 +}
    1.41 +
    1.42 +HRESULT CLocalProgress::SetCur()
    1.43 +{
    1.44 +  return SetRatioInfo(NULL, NULL);
    1.45 +}