Mercurial > vba-linux
diff src/win32/7zip/7z/CPP/7zip/Common/OffsetStream.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 diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/win32/7zip/7z/CPP/7zip/Common/OffsetStream.cpp Sat Mar 03 10:31:27 2012 -0600 1.3 @@ -0,0 +1,35 @@ 1.4 +// OffsetStream.cpp 1.5 + 1.6 +#include "StdAfx.h" 1.7 + 1.8 +#include "Common/Defs.h" 1.9 +#include "OffsetStream.h" 1.10 + 1.11 +HRESULT COffsetOutStream::Init(IOutStream *stream, UInt64 offset) 1.12 +{ 1.13 + _offset = offset; 1.14 + _stream = stream; 1.15 + return _stream->Seek(offset, STREAM_SEEK_SET, NULL); 1.16 +} 1.17 + 1.18 +STDMETHODIMP COffsetOutStream::Write(const void *data, UInt32 size, UInt32 *processedSize) 1.19 +{ 1.20 + return _stream->Write(data, size, processedSize); 1.21 +} 1.22 + 1.23 +STDMETHODIMP COffsetOutStream::Seek(Int64 offset, UInt32 seekOrigin, 1.24 + UInt64 *newPosition) 1.25 +{ 1.26 + UInt64 absoluteNewPosition; 1.27 + if (seekOrigin == STREAM_SEEK_SET) 1.28 + offset += _offset; 1.29 + HRESULT result = _stream->Seek(offset, seekOrigin, &absoluteNewPosition); 1.30 + if (newPosition != NULL) 1.31 + *newPosition = absoluteNewPosition - _offset; 1.32 + return result; 1.33 +} 1.34 + 1.35 +STDMETHODIMP COffsetOutStream::SetSize(Int64 newSize) 1.36 +{ 1.37 + return _stream->SetSize(_offset + newSize); 1.38 +}