|
1 // ProgressUtils.h |
|
2 |
|
3 #include "StdAfx.h" |
|
4 |
|
5 #include "ProgressUtils.h" |
|
6 |
|
7 void CLocalCompressProgressInfo::Init(ICompressProgressInfo *progress, |
|
8 const UInt64 *inStartValue, const UInt64 *outStartValue) |
|
9 { |
|
10 _progress = progress; |
|
11 _inStartValueIsAssigned = (inStartValue != NULL); |
|
12 if (_inStartValueIsAssigned) |
|
13 _inStartValue = *inStartValue; |
|
14 _outStartValueIsAssigned = (outStartValue != NULL); |
|
15 if (_outStartValueIsAssigned) |
|
16 _outStartValue = *outStartValue; |
|
17 } |
|
18 |
|
19 STDMETHODIMP CLocalCompressProgressInfo::SetRatioInfo( |
|
20 const UInt64 *inSize, const UInt64 *outSize) |
|
21 { |
|
22 UInt64 inSizeNew, outSizeNew; |
|
23 const UInt64 *inSizeNewPointer; |
|
24 const UInt64 *outSizeNewPointer; |
|
25 if (_inStartValueIsAssigned && inSize != NULL) |
|
26 { |
|
27 inSizeNew = _inStartValue + (*inSize); |
|
28 inSizeNewPointer = &inSizeNew; |
|
29 } |
|
30 else |
|
31 inSizeNewPointer = NULL; |
|
32 |
|
33 if (_outStartValueIsAssigned && outSize != NULL) |
|
34 { |
|
35 outSizeNew = _outStartValue + (*outSize); |
|
36 outSizeNewPointer = &outSizeNew; |
|
37 } |
|
38 else |
|
39 outSizeNewPointer = NULL; |
|
40 return _progress->SetRatioInfo(inSizeNewPointer, outSizeNewPointer); |
|
41 } |
|
42 |
|
43 |
|
44 /////////////////////////////////// |
|
45 // |
|
46 |
|
47 void CLocalProgress::Init(IProgress *progress, bool inSizeIsMain) |
|
48 { |
|
49 _progress = progress; |
|
50 _inSizeIsMain = inSizeIsMain; |
|
51 } |
|
52 |
|
53 STDMETHODIMP CLocalProgress::SetRatioInfo( |
|
54 const UInt64 *inSize, const UInt64 *outSize) |
|
55 { |
|
56 return _progress->SetCompleted(_inSizeIsMain ? inSize : outSize); |
|
57 } |
|
58 |