This commit is contained in:
Igor Pavlov
2003-12-11 00:00:00 +00:00
committed by Kornel Lesiński
commit 8c1b5c7b7e
982 changed files with 118799 additions and 0 deletions

41
7zip/Common/OffsetStream.cpp Executable file
View File

@@ -0,0 +1,41 @@
// OffsetStream.cpp
#include "StdAfx.h"
#include "Common/Defs.h"
#include "OffsetStream.h"
HRESULT COffsetOutStream::Init(IOutStream *stream, UINT64 offset)
{
_offset = offset;
_stream = stream;
return _stream->Seek(offset, STREAM_SEEK_SET, NULL);
}
STDMETHODIMP COffsetOutStream::Write(const void *data, UINT32 size,
UINT32 *processedSize)
{
return _stream->Write(data, size, processedSize);
}
STDMETHODIMP COffsetOutStream::WritePart(const void *data, UINT32 size, UINT32 *processedSize)
{
return _stream->WritePart(data, size, processedSize);
}
STDMETHODIMP COffsetOutStream::Seek(INT64 offset, UINT32 seekOrigin,
UINT64 *newPosition)
{
UINT64 absoluteNewPosition;
if (seekOrigin == STREAM_SEEK_SET)
offset += _offset;
HRESULT result = _stream->Seek(offset, seekOrigin, &absoluteNewPosition);
if (newPosition != NULL)
*newPosition = absoluteNewPosition - _offset;
return result;
}
STDMETHODIMP COffsetOutStream::SetSize(INT64 newSize)
{
return _stream->SetSize(_offset + newSize);
}