Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1753)

Side by Side Diff: third_party/lzma/v4_65/files/CPP/7zip/Compress/CopyCoder.cpp

Issue 624713003: Keep only base/extractor.[cc|h]. (Closed) Base URL: https://chromium.googlesource.com/external/omaha.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Compress/CopyCoder.cpp
2
3 #include "StdAfx.h"
4
5 extern "C"
6 {
7 #include "../../../C/Alloc.h"
8 }
9
10 #include "../Common/StreamUtils.h"
11
12 #include "CopyCoder.h"
13
14 namespace NCompress {
15
16 static const UInt32 kBufferSize = 1 << 17;
17
18 CCopyCoder::~CCopyCoder()
19 {
20 ::MidFree(_buffer);
21 }
22
23 STDMETHODIMP CCopyCoder::Code(ISequentialInStream *inStream,
24 ISequentialOutStream *outStream,
25 const UInt64 * /* inSize */, const UInt64 *outSize,
26 ICompressProgressInfo *progress)
27 {
28 if (_buffer == 0)
29 {
30 _buffer = (Byte *)::MidAlloc(kBufferSize);
31 if (_buffer == 0)
32 return E_OUTOFMEMORY;
33 }
34
35 TotalSize = 0;
36 for (;;)
37 {
38 UInt32 realProcessedSize;
39 UInt32 size = kBufferSize;
40 if (outSize != 0)
41 if (size > *outSize - TotalSize)
42 size = (UInt32)(*outSize - TotalSize);
43 RINOK(inStream->Read(_buffer, size, &realProcessedSize));
44 if (realProcessedSize == 0)
45 break;
46 RINOK(WriteStream(outStream, _buffer, realProcessedSize));
47 TotalSize += realProcessedSize;
48 if (progress != NULL)
49 {
50 RINOK(progress->SetRatioInfo(&TotalSize, &TotalSize));
51 }
52 }
53 return S_OK;
54 }
55
56 STDMETHODIMP CCopyCoder::GetInStreamProcessedSize(UInt64 *value)
57 {
58 *value = TotalSize;
59 return S_OK;
60 }
61
62 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698