xref: /third_party/lzma/CPP/7zip/Common/ProgressUtils.cpp (revision 370b324c)
  • Home
  • History
  • Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/lzma/CPP/7zip/Common/
1// ProgressUtils.cpp
2
3#include "StdAfx.h"
4
5#include "ProgressUtils.h"
6
7CLocalProgress::CLocalProgress():
8    SendRatio(true),
9    SendProgress(true),
10    ProgressOffset(0),
11    InSize(0),
12    OutSize(0)
13  {}
14
15void CLocalProgress::Init(IProgress *progress, bool inSizeIsMain)
16{
17  _ratioProgress.Release();
18  _progress = progress;
19  _progress.QueryInterface(IID_ICompressProgressInfo, &_ratioProgress);
20  _inSizeIsMain = inSizeIsMain;
21}
22
23Z7_COM7F_IMF(CLocalProgress::SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize))
24{
25  UInt64 inSize2 = InSize;
26  UInt64 outSize2 = OutSize;
27
28  if (inSize)
29    inSize2 += (*inSize);
30  if (outSize)
31    outSize2 += (*outSize);
32
33  if (SendRatio && _ratioProgress)
34  {
35    RINOK(_ratioProgress->SetRatioInfo(&inSize2, &outSize2))
36  }
37
38  if (SendProgress)
39  {
40    inSize2 += ProgressOffset;
41    outSize2 += ProgressOffset;
42    return _progress->SetCompleted(_inSizeIsMain ? &inSize2 : &outSize2);
43  }
44
45  return S_OK;
46}
47
48HRESULT CLocalProgress::SetCur()
49{
50  return SetRatioInfo(NULL, NULL);
51}
52

Indexes created Thu Nov 07 10:32:03 CST 2024