summaryrefslogtreecommitdiffstats
path: root/other-licenses/7zstub/src/7zip/Common/ProgressUtils.cpp
blob: ac598cd5453e0e00742e989efa6692ade39f405f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// ProgressUtils.h

#include "StdAfx.h"

#include "ProgressUtils.h"

void CLocalCompressProgressInfo::Init(ICompressProgressInfo *progress,
    const UInt64 *inStartValue, const UInt64 *outStartValue)
{
  _progress = progress;
  _inStartValueIsAssigned = (inStartValue != NULL);
  if (_inStartValueIsAssigned)
    _inStartValue = *inStartValue;
  _outStartValueIsAssigned = (outStartValue != NULL);
  if (_outStartValueIsAssigned)
    _outStartValue = *outStartValue;
}

STDMETHODIMP CLocalCompressProgressInfo::SetRatioInfo(
    const UInt64 *inSize, const UInt64 *outSize)
{
  UInt64 inSizeNew, outSizeNew;
  const UInt64 *inSizeNewPointer;
  const UInt64 *outSizeNewPointer;
  if (_inStartValueIsAssigned && inSize != NULL)
  {
    inSizeNew = _inStartValue + (*inSize);
    inSizeNewPointer = &inSizeNew;
  }
  else
    inSizeNewPointer = NULL;

  if (_outStartValueIsAssigned && outSize != NULL)
  {
    outSizeNew = _outStartValue + (*outSize);
    outSizeNewPointer = &outSizeNew;
  }
  else
    outSizeNewPointer = NULL;
  return _progress->SetRatioInfo(inSizeNewPointer, outSizeNewPointer);
}


///////////////////////////////////
// 

void CLocalProgress::Init(IProgress *progress, bool inSizeIsMain)
{
  _progress = progress;
  _inSizeIsMain = inSizeIsMain;
}

STDMETHODIMP CLocalProgress::SetRatioInfo(
    const UInt64 *inSize, const UInt64 *outSize)
{
  return _progress->SetCompleted(_inSizeIsMain ? inSize : outSize);
}