5 #include "StreamObjects.h"
6 #include "../../Common/Defs.h"
9 STDMETHODIMP CSequentialInStreamImp::Read(void *data, UInt32 size, UInt32 *processedSize)
11 UInt32 numBytesToRead = (UInt32)(MyMin(_pos + size, _size) - _pos);
12 memmove(data, _dataPointer + _pos, numBytesToRead);
13 _pos += numBytesToRead;
14 if(processedSize != NULL)
15 *processedSize = numBytesToRead;
20 void CWriteBuffer::Write(const void *data, size_t size)
22 size_t newCapacity = _size + size;
23 _buffer.EnsureCapacity(newCapacity);
24 memmove(_buffer + _size, data, size);
28 STDMETHODIMP CSequentialOutStreamImp::Write(const void *data, UInt32 size, UInt32 *processedSize)
30 _writeBuffer.Write(data, size);
31 if(processedSize != NULL)
32 *processedSize = size;
36 STDMETHODIMP CSequentialOutStreamImp2::Write(const void *data, UInt32 size, UInt32 *processedSize)
38 UInt32 newSize = size;
39 if (_pos + size > _size)
40 newSize = (UInt32)(_size - _pos);
41 memmove(_buffer + _pos, data, newSize);
42 if(processedSize != NULL)
43 *processedSize = newSize;
50 STDMETHODIMP CSequentialInStreamSizeCount::Read(void *data, UInt32 size, UInt32 *processedSize)
52 UInt32 realProcessedSize;
53 HRESULT result = _stream->Read(data, size, &realProcessedSize);
54 _size += realProcessedSize;
55 if (processedSize != 0)
56 *processedSize = realProcessedSize;
60 STDMETHODIMP CSequentialOutStreamSizeCount::Write(const void *data, UInt32 size, UInt32 *processedSize)
62 UInt32 realProcessedSize;
63 HRESULT result = _stream->Write(data, size, &realProcessedSize);
64 _size += realProcessedSize;
65 if (processedSize != 0)
66 *processedSize = realProcessedSize;