diff src/win32/7zip/7z/CPP/7zip/Common/ProgressMt.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/ProgressMt.cpp	Sat Mar 03 10:31:27 2012 -0600
     1.3 @@ -0,0 +1,53 @@
     1.4 +// ProgressMt.h
     1.5 +
     1.6 +#include "StdAfx.h"
     1.7 +
     1.8 +#include "ProgressMt.h"
     1.9 +
    1.10 +void CMtCompressProgressMixer::Init(int numItems, ICompressProgressInfo *progress)
    1.11 +{
    1.12 +  NWindows::NSynchronization::CCriticalSectionLock lock(CriticalSection);
    1.13 +  InSizes.Clear();
    1.14 +  OutSizes.Clear();
    1.15 +  for (int i = 0; i < numItems; i++)
    1.16 +  {
    1.17 +    InSizes.Add(0);
    1.18 +    OutSizes.Add(0);
    1.19 +  }
    1.20 +  TotalInSize = 0;
    1.21 +  TotalOutSize = 0;
    1.22 +  _progress = progress;
    1.23 +}
    1.24 +
    1.25 +void CMtCompressProgressMixer::Reinit(int index)
    1.26 +{
    1.27 +  NWindows::NSynchronization::CCriticalSectionLock lock(CriticalSection);
    1.28 +  InSizes[index] = 0;
    1.29 +  OutSizes[index] = 0;
    1.30 +}
    1.31 +
    1.32 +HRESULT CMtCompressProgressMixer::SetRatioInfo(int index, const UInt64 *inSize, const UInt64 *outSize)
    1.33 +{
    1.34 +  NWindows::NSynchronization::CCriticalSectionLock lock(CriticalSection);
    1.35 +  if (inSize != 0)
    1.36 +  {
    1.37 +    UInt64 diff = *inSize - InSizes[index];
    1.38 +    InSizes[index] = *inSize;
    1.39 +    TotalInSize += diff;
    1.40 +  }
    1.41 +  if (outSize != 0)
    1.42 +  {
    1.43 +    UInt64 diff = *outSize - OutSizes[index];
    1.44 +    OutSizes[index] = *outSize;
    1.45 +    TotalOutSize += diff;
    1.46 +  }
    1.47 +  if (_progress)
    1.48 +    return _progress->SetRatioInfo(&TotalInSize, &TotalOutSize);
    1.49 +  return S_OK;
    1.50 +}
    1.51 +
    1.52 +
    1.53 +STDMETHODIMP CMtCompressProgress::SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize)
    1.54 +{
    1.55 +  return _progress->SetRatioInfo(_index, inSize, outSize);
    1.56 +}