Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | // OffsetStream.cpp |
michael@0 | 2 | |
michael@0 | 3 | #include "StdAfx.h" |
michael@0 | 4 | |
michael@0 | 5 | #include "Common/Defs.h" |
michael@0 | 6 | #include "OffsetStream.h" |
michael@0 | 7 | |
michael@0 | 8 | HRESULT COffsetOutStream::Init(IOutStream *stream, UInt64 offset) |
michael@0 | 9 | { |
michael@0 | 10 | _offset = offset; |
michael@0 | 11 | _stream = stream; |
michael@0 | 12 | return _stream->Seek(offset, STREAM_SEEK_SET, NULL); |
michael@0 | 13 | } |
michael@0 | 14 | |
michael@0 | 15 | STDMETHODIMP COffsetOutStream::Write(const void *data, UInt32 size, UInt32 *processedSize) |
michael@0 | 16 | { |
michael@0 | 17 | return _stream->Write(data, size, processedSize); |
michael@0 | 18 | } |
michael@0 | 19 | |
michael@0 | 20 | STDMETHODIMP COffsetOutStream::Seek(Int64 offset, UInt32 seekOrigin, |
michael@0 | 21 | UInt64 *newPosition) |
michael@0 | 22 | { |
michael@0 | 23 | UInt64 absoluteNewPosition; |
michael@0 | 24 | if (seekOrigin == STREAM_SEEK_SET) |
michael@0 | 25 | offset += _offset; |
michael@0 | 26 | HRESULT result = _stream->Seek(offset, seekOrigin, &absoluteNewPosition); |
michael@0 | 27 | if (newPosition != NULL) |
michael@0 | 28 | *newPosition = absoluteNewPosition - _offset; |
michael@0 | 29 | return result; |
michael@0 | 30 | } |
michael@0 | 31 | |
michael@0 | 32 | STDMETHODIMP COffsetOutStream::SetSize(Int64 newSize) |
michael@0 | 33 | { |
michael@0 | 34 | return _stream->SetSize(_offset + newSize); |
michael@0 | 35 | } |