diff options
Diffstat (limited to '3rdparty/lzma/CPP/7zip/Common/InOutTempBuffer.cpp')
-rw-r--r-- | 3rdparty/lzma/CPP/7zip/Common/InOutTempBuffer.cpp | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/3rdparty/lzma/CPP/7zip/Common/InOutTempBuffer.cpp b/3rdparty/lzma/CPP/7zip/Common/InOutTempBuffer.cpp index 442374dab79..85d6a1aa921 100644 --- a/3rdparty/lzma/CPP/7zip/Common/InOutTempBuffer.cpp +++ b/3rdparty/lzma/CPP/7zip/Common/InOutTempBuffer.cpp @@ -4,14 +4,16 @@ #include "../../../C/7zCrc.h" +#include "../../Common/Defs.h" + #include "InOutTempBuffer.h" #include "StreamUtils.h" using namespace NWindows; using namespace NFile; -using namespace NDirectory; +using namespace NDir; -static const UInt32 kTempBufSize = (1 << 20); +static const size_t kTempBufSize = (1 << 20); static CFSTR kTempFilePrefixString = FTEXT("7zt"); @@ -56,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); } @@ -77,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; @@ -100,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; } +*/ |