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

Side by Side Diff: third_party/lzma/v4_65/files/CPP/7zip/Common/StreamUtils.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 // StreamUtils.cpp
2
3 #include "StdAfx.h"
4
5 #include "StreamUtils.h"
6
7 static const UInt32 kBlockSize = ((UInt32)1 << 31);
8
9 HRESULT ReadStream(ISequentialInStream *stream, void *data, size_t *processedSiz e)
10 {
11 size_t size = *processedSize;
12 *processedSize = 0;
13 while (size != 0)
14 {
15 UInt32 curSize = (size < kBlockSize) ? (UInt32)size : kBlockSize;
16 UInt32 processedSizeLoc;
17 HRESULT res = stream->Read(data, curSize, &processedSizeLoc);
18 *processedSize += processedSizeLoc;
19 data = (void *)((Byte *)data + processedSizeLoc);
20 size -= processedSizeLoc;
21 RINOK(res);
22 if (processedSizeLoc == 0)
23 return S_OK;
24 }
25 return S_OK;
26 }
27
28 HRESULT ReadStream_FALSE(ISequentialInStream *stream, void *data, size_t size)
29 {
30 size_t processedSize = size;
31 RINOK(ReadStream(stream, data, &processedSize));
32 return (size == processedSize) ? S_OK : S_FALSE;
33 }
34
35 HRESULT ReadStream_FAIL(ISequentialInStream *stream, void *data, size_t size)
36 {
37 size_t processedSize = size;
38 RINOK(ReadStream(stream, data, &processedSize));
39 return (size == processedSize) ? S_OK : E_FAIL;
40 }
41
42 HRESULT WriteStream(ISequentialOutStream *stream, const void *data, size_t size)
43 {
44 while (size != 0)
45 {
46 UInt32 curSize = (size < kBlockSize) ? (UInt32)size : kBlockSize;
47 UInt32 processedSizeLoc;
48 HRESULT res = stream->Write(data, curSize, &processedSizeLoc);
49 data = (const void *)((const Byte *)data + processedSizeLoc);
50 size -= processedSizeLoc;
51 RINOK(res);
52 if (processedSizeLoc == 0)
53 return E_FAIL;
54 }
55 return S_OK;
56 }
OLDNEW
« no previous file with comments | « third_party/lzma/v4_65/files/CPP/7zip/Common/StreamUtils.h ('k') | third_party/lzma/v4_65/files/CPP/7zip/Common/VirtThread.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698