mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-11 12:07:12 -06:00
4.20
This commit is contained in:
committed by
Kornel Lesiński
parent
8c1b5c7b7e
commit
3c510ba80b
@@ -5,6 +5,7 @@
|
||||
#include "StreamObjects.h"
|
||||
#include "../../Common/Defs.h"
|
||||
|
||||
/*
|
||||
STDMETHODIMP COutStreamImp::Read(void *data, ULONG size, ULONG *processedSize)
|
||||
{ return E_NOTIMPL; }
|
||||
|
||||
@@ -19,7 +20,7 @@ STDMETHODIMP COutStreamImp::Write(void const *data, ULONG size, ULONG *processed
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
void CInStreamImp::Init(BYTE *dataPointer, UINT32 size)
|
||||
void CInStreamImp::Init(Byte *dataPointer, size_t size)
|
||||
{
|
||||
_dataPointer = dataPointer;
|
||||
_size = size;
|
||||
@@ -28,7 +29,7 @@ void CInStreamImp::Init(BYTE *dataPointer, UINT32 size)
|
||||
|
||||
STDMETHODIMP CInStreamImp::Read(void *data, ULONG size, ULONG *processedSize)
|
||||
{
|
||||
UINT32 numBytesToRead = MyMin(_pos + (UINT32)size, _size) - _pos;
|
||||
UInt32 numBytesToRead = MyMin(_pos + (UInt32)size, _size) - _pos;
|
||||
if(processedSize != NULL)
|
||||
*processedSize = numBytesToRead;
|
||||
memmove(data, _dataPointer + _pos, numBytesToRead);
|
||||
@@ -41,12 +42,12 @@ STDMETHODIMP CInStreamImp::Read(void *data, ULONG size, ULONG *processedSize)
|
||||
|
||||
STDMETHODIMP CInStreamImp::Write(void const *data, ULONG size, ULONG *processedSize)
|
||||
{ return E_NOTIMPL; }
|
||||
*/
|
||||
|
||||
|
||||
|
||||
STDMETHODIMP CSequentialInStreamImp::Read(void *data, UINT32 size, UINT32 *processedSize)
|
||||
STDMETHODIMP CSequentialInStreamImp::Read(void *data, UInt32 size, UInt32 *processedSize)
|
||||
{
|
||||
UINT32 numBytesToRead = MyMin(_pos + size, _size) - _pos;
|
||||
UInt32 numBytesToRead = (UInt32)(MyMin(_pos + size, _size) - _pos);
|
||||
memmove(data, _dataPointer + _pos, numBytesToRead);
|
||||
_pos += numBytesToRead;
|
||||
if(processedSize != NULL)
|
||||
@@ -54,7 +55,7 @@ STDMETHODIMP CSequentialInStreamImp::Read(void *data, UINT32 size, UINT32 *proce
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CSequentialInStreamImp::ReadPart(void *data, UINT32 size, UINT32 *processedSize)
|
||||
STDMETHODIMP CSequentialInStreamImp::ReadPart(void *data, UInt32 size, UInt32 *processedSize)
|
||||
{
|
||||
return Read(data, size, processedSize);
|
||||
}
|
||||
@@ -62,7 +63,7 @@ STDMETHODIMP CSequentialInStreamImp::ReadPart(void *data, UINT32 size, UINT32 *p
|
||||
////////////////////
|
||||
|
||||
|
||||
void CWriteBuffer::Write(const void *data, UINT32 size)
|
||||
void CWriteBuffer::Write(const void *data, size_t size)
|
||||
{
|
||||
size_t newCapacity = _size + size;
|
||||
_buffer.EnsureCapacity(newCapacity);
|
||||
@@ -70,7 +71,7 @@ void CWriteBuffer::Write(const void *data, UINT32 size)
|
||||
_size += size;
|
||||
}
|
||||
|
||||
STDMETHODIMP CSequentialOutStreamImp::Write(const void *data, UINT32 size, UINT32 *processedSize)
|
||||
STDMETHODIMP CSequentialOutStreamImp::Write(const void *data, UInt32 size, UInt32 *processedSize)
|
||||
{
|
||||
_writeBuffer.Write(data, size);
|
||||
if(processedSize != NULL)
|
||||
@@ -78,14 +79,14 @@ STDMETHODIMP CSequentialOutStreamImp::Write(const void *data, UINT32 size, UINT3
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CSequentialOutStreamImp::WritePart(const void *data, UINT32 size, UINT32 *processedSize)
|
||||
STDMETHODIMP CSequentialOutStreamImp::WritePart(const void *data, UInt32 size, UInt32 *processedSize)
|
||||
{
|
||||
return Write(data, size, processedSize);
|
||||
}
|
||||
|
||||
STDMETHODIMP CSequentialOutStreamImp2::Write(const void *data, UINT32 size, UINT32 *processedSize)
|
||||
STDMETHODIMP CSequentialOutStreamImp2::Write(const void *data, UInt32 size, UInt32 *processedSize)
|
||||
{
|
||||
UINT32 newSize = size;
|
||||
UInt32 newSize = size;
|
||||
if (_pos + size > _size)
|
||||
newSize = _size - _pos;
|
||||
memmove(_buffer + _pos, data, newSize);
|
||||
@@ -97,16 +98,16 @@ STDMETHODIMP CSequentialOutStreamImp2::Write(const void *data, UINT32 size, UINT
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CSequentialOutStreamImp2::WritePart(const void *data, UINT32 size, UINT32 *processedSize)
|
||||
STDMETHODIMP CSequentialOutStreamImp2::WritePart(const void *data, UInt32 size, UInt32 *processedSize)
|
||||
{
|
||||
return Write(data, size, processedSize);
|
||||
}
|
||||
|
||||
|
||||
|
||||
STDMETHODIMP CSequentialInStreamSizeCount::Read(void *data, UINT32 size, UINT32 *processedSize)
|
||||
STDMETHODIMP CSequentialInStreamSizeCount::Read(void *data, UInt32 size, UInt32 *processedSize)
|
||||
{
|
||||
UINT32 realProcessedSize;
|
||||
UInt32 realProcessedSize;
|
||||
HRESULT result = _stream->Read(data, size, &realProcessedSize);
|
||||
_size += realProcessedSize;
|
||||
if (processedSize != 0)
|
||||
@@ -114,9 +115,9 @@ STDMETHODIMP CSequentialInStreamSizeCount::Read(void *data, UINT32 size, UINT32
|
||||
return result;
|
||||
}
|
||||
|
||||
STDMETHODIMP CSequentialInStreamSizeCount::ReadPart(void *data, UINT32 size, UINT32 *processedSize)
|
||||
STDMETHODIMP CSequentialInStreamSizeCount::ReadPart(void *data, UInt32 size, UInt32 *processedSize)
|
||||
{
|
||||
UINT32 realProcessedSize;
|
||||
UInt32 realProcessedSize;
|
||||
HRESULT result = _stream->ReadPart(data, size, &realProcessedSize);
|
||||
_size += realProcessedSize;
|
||||
if (processedSize != 0)
|
||||
@@ -124,10 +125,63 @@ STDMETHODIMP CSequentialInStreamSizeCount::ReadPart(void *data, UINT32 size, UIN
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
STDMETHODIMP CSequentialOutStreamSizeCount::Write(const void *data, UINT32 size, UINT32 *processedSize)
|
||||
STDMETHODIMP CSequentialInStreamRollback::Read(void *data, UInt32 size, UInt32 *processedSize)
|
||||
{
|
||||
UINT32 realProcessedSize;
|
||||
HRESULT result = S_OK;
|
||||
UInt32 realProcessedSizeTotal = 0;
|
||||
while (size > 0)
|
||||
{
|
||||
UInt32 realProcessedSize = 0;
|
||||
result = ReadPart(data, size, &realProcessedSize);
|
||||
size -= realProcessedSize;
|
||||
data = ((Byte *)data + realProcessedSize);
|
||||
realProcessedSizeTotal += realProcessedSize;
|
||||
if (realProcessedSize == 0 || result != S_OK)
|
||||
break;
|
||||
}
|
||||
if (processedSize != 0)
|
||||
*processedSize = realProcessedSizeTotal;
|
||||
return result;
|
||||
}
|
||||
|
||||
STDMETHODIMP CSequentialInStreamRollback::ReadPart(void *data, UInt32 size, UInt32 *processedSize)
|
||||
{
|
||||
if (_currentPos != _currentSize)
|
||||
{
|
||||
UInt32 curSize = _currentSize - _currentPos;
|
||||
if (size > curSize)
|
||||
size = curSize;
|
||||
memmove(data, _buffer + _currentPos, size);
|
||||
_currentPos += size;
|
||||
if (processedSize != 0)
|
||||
*processedSize = size;
|
||||
return S_OK;
|
||||
}
|
||||
UInt32 realProcessedSize;
|
||||
if (size > _bufferSize)
|
||||
size = _bufferSize;
|
||||
HRESULT result = _stream->ReadPart(_buffer, size, &realProcessedSize);
|
||||
memmove(data, _buffer, realProcessedSize);
|
||||
_size += realProcessedSize;
|
||||
_currentSize = realProcessedSize;
|
||||
_currentPos = realProcessedSize;
|
||||
if (processedSize != 0)
|
||||
*processedSize = realProcessedSize;
|
||||
return result;
|
||||
}
|
||||
|
||||
HRESULT CSequentialInStreamRollback::Rollback(size_t rollbackSize)
|
||||
{
|
||||
if (rollbackSize > _currentPos)
|
||||
return E_INVALIDARG;
|
||||
_currentPos -= rollbackSize;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
STDMETHODIMP CSequentialOutStreamSizeCount::Write(const void *data, UInt32 size, UInt32 *processedSize)
|
||||
{
|
||||
UInt32 realProcessedSize;
|
||||
HRESULT result = _stream->Write(data, size, &realProcessedSize);
|
||||
_size += realProcessedSize;
|
||||
if (processedSize != 0)
|
||||
@@ -135,9 +189,9 @@ STDMETHODIMP CSequentialOutStreamSizeCount::Write(const void *data, UINT32 size,
|
||||
return result;
|
||||
}
|
||||
|
||||
STDMETHODIMP CSequentialOutStreamSizeCount::WritePart(const void *data, UINT32 size, UINT32 *processedSize)
|
||||
STDMETHODIMP CSequentialOutStreamSizeCount::WritePart(const void *data, UInt32 size, UInt32 *processedSize)
|
||||
{
|
||||
UINT32 realProcessedSize;
|
||||
UInt32 realProcessedSize;
|
||||
HRESULT result = _stream->WritePart(data, size, &realProcessedSize);
|
||||
_size += realProcessedSize;
|
||||
if (processedSize != 0)
|
||||
|
||||
Reference in New Issue
Block a user