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