mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-07 11:14:58 -06:00
15.05
This commit is contained in:
committed by
Kornel Lesiński
parent
0713a3ab80
commit
54490d51d5
@@ -13,7 +13,7 @@ using namespace NWindows;
|
||||
using namespace NFile;
|
||||
using namespace NDir;
|
||||
|
||||
static const UInt32 kTempBufSize = (1 << 20);
|
||||
static const size_t kTempBufSize = (1 << 20);
|
||||
|
||||
static CFSTR kTempFilePrefixString = FTEXT("7zt");
|
||||
|
||||
@@ -58,15 +58,19 @@ bool CInOutTempBuffer::WriteToFile(const void *data, UInt32 size)
|
||||
|
||||
bool CInOutTempBuffer::Write(const void *data, UInt32 size)
|
||||
{
|
||||
if (_bufPos < kTempBufSize)
|
||||
if (size == 0)
|
||||
return true;
|
||||
size_t cur = kTempBufSize - _bufPos;
|
||||
if (cur != 0)
|
||||
{
|
||||
UInt32 cur = MyMin(kTempBufSize - _bufPos, size);
|
||||
if (cur > size)
|
||||
cur = size;
|
||||
memcpy(_buf + _bufPos, data, cur);
|
||||
_crc = CrcUpdate(_crc, data, cur);
|
||||
_bufPos += cur;
|
||||
size -= cur;
|
||||
data = ((const Byte *)data) + cur;
|
||||
_size += cur;
|
||||
size -= (UInt32)cur;
|
||||
data = ((const Byte *)data) + cur;
|
||||
}
|
||||
return WriteToFile(data, size);
|
||||
}
|
||||
@@ -79,12 +83,13 @@ HRESULT CInOutTempBuffer::WriteToStream(ISequentialOutStream *stream)
|
||||
UInt64 size = 0;
|
||||
UInt32 crc = CRC_INIT_VAL;
|
||||
|
||||
if (_bufPos > 0)
|
||||
if (_bufPos != 0)
|
||||
{
|
||||
RINOK(WriteStream(stream, _buf, _bufPos));
|
||||
crc = CrcUpdate(crc, _buf, _bufPos);
|
||||
size += _bufPos;
|
||||
}
|
||||
|
||||
if (_tempFileCreated)
|
||||
{
|
||||
NIO::CInFile inFile;
|
||||
@@ -102,18 +107,21 @@ HRESULT CInOutTempBuffer::WriteToStream(ISequentialOutStream *stream)
|
||||
size += processed;
|
||||
}
|
||||
}
|
||||
|
||||
return (_crc == crc && size == _size) ? S_OK : E_FAIL;
|
||||
}
|
||||
|
||||
/*
|
||||
STDMETHODIMP CSequentialOutTempBufferImp::Write(const void *data, UInt32 size, UInt32 *processed)
|
||||
{
|
||||
if (!_buf->Write(data, size))
|
||||
{
|
||||
if (processed != NULL)
|
||||
if (processed)
|
||||
*processed = 0;
|
||||
return E_FAIL;
|
||||
}
|
||||
if (processed != NULL)
|
||||
if (processed)
|
||||
*processed = size;
|
||||
return S_OK;
|
||||
}
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user