Mercurial > vba-linux
view src/win32/7zip/7z/CPP/7zip/Common/LimitedStreams.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 source
1 // LimitedStreams.cpp3 #include "StdAfx.h"5 #include "LimitedStreams.h"6 #include "../../Common/Defs.h"8 STDMETHODIMP CLimitedSequentialInStream::Read(void *data, UInt32 size, UInt32 *processedSize)9 {10 UInt32 realProcessedSize = 0;11 UInt32 sizeToRead = (UInt32)MyMin((_size - _pos), (UInt64)size);12 HRESULT result = S_OK;13 if (sizeToRead > 0)14 {15 result = _stream->Read(data, sizeToRead, &realProcessedSize);16 _pos += realProcessedSize;17 if (realProcessedSize == 0)18 _wasFinished = true;19 }20 if(processedSize != NULL)21 *processedSize = realProcessedSize;22 return result;23 }25 STDMETHODIMP CLimitedSequentialOutStream::Write(const void *data, UInt32 size, UInt32 *processedSize)26 {27 HRESULT result = S_OK;28 if (processedSize != NULL)29 *processedSize = 0;30 if (size > _size)31 {32 size = (UInt32)_size;33 if (size == 0)34 {35 _overflow = true;36 return E_FAIL;37 }38 }39 if (_stream)40 result = _stream->Write(data, size, &size);41 _size -= size;42 if (processedSize != NULL)43 *processedSize = size;44 return result;45 }