1 // Compress/CopyCoder.cpp
7 #include "../../../../C/Alloc.h"
10 #include "CopyCoder.h"
11 #include "../../Common/StreamUtils.h"
15 static const UInt32 kBufferSize = 1 << 17;
17 CCopyCoder::~CCopyCoder()
22 STDMETHODIMP CCopyCoder::Code(ISequentialInStream *inStream,
23 ISequentialOutStream *outStream,
24 const UInt64 * /* inSize */, const UInt64 *outSize,
25 ICompressProgressInfo *progress)
29 _buffer = (Byte *)::MidAlloc(kBufferSize);
37 UInt32 realProcessedSize;
38 UInt32 size = kBufferSize;
40 if (size > *outSize - TotalSize)
41 size = (UInt32)(*outSize - TotalSize);
42 RINOK(inStream->Read(_buffer, size, &realProcessedSize));
43 if (realProcessedSize == 0)
45 RINOK(WriteStream(outStream, _buffer, realProcessedSize, NULL));
46 TotalSize += realProcessedSize;
49 RINOK(progress->SetRatioInfo(&TotalSize, &TotalSize));
55 STDMETHODIMP CCopyCoder::GetInStreamProcessedSize(UInt64 *value)