Bug 470455 - test_database_sync_embed_visits.js leaks, r=sdwilsh
[wine-gecko.git] / other-licenses / 7zstub / src / 7zip / Common / OffsetStream.cpp
blob177401f38310338af3a5c9b952b51769a34bc93c
1 // OffsetStream.cpp
3 #include "StdAfx.h"
5 #include "Common/Defs.h"
6 #include "OffsetStream.h"
8 HRESULT COffsetOutStream::Init(IOutStream *stream, UInt64 offset)
10 _offset = offset;
11 _stream = stream;
12 return _stream->Seek(offset, STREAM_SEEK_SET, NULL);
15 STDMETHODIMP COffsetOutStream::Write(const void *data, UInt32 size, UInt32 *processedSize)
17 return _stream->Write(data, size, processedSize);
20 STDMETHODIMP COffsetOutStream::Seek(Int64 offset, UInt32 seekOrigin,
21 UInt64 *newPosition)
23 UInt64 absoluteNewPosition;
24 if (seekOrigin == STREAM_SEEK_SET)
25 offset += _offset;
26 HRESULT result = _stream->Seek(offset, seekOrigin, &absoluteNewPosition);
27 if (newPosition != NULL)
28 *newPosition = absoluteNewPosition - _offset;
29 return result;
32 STDMETHODIMP COffsetOutStream::SetSize(Int64 newSize)
34 return _stream->SetSize(_offset + newSize);