Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/kornelski/7z.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'CPP/7zip/Common/InOutTempBuffer.cpp')
-rw-r--r--CPP/7zip/Common/InOutTempBuffer.cpp24
1 files changed, 16 insertions, 8 deletions
diff --git a/CPP/7zip/Common/InOutTempBuffer.cpp b/CPP/7zip/Common/InOutTempBuffer.cpp
index be65ba32..85d6a1aa 100644
--- a/CPP/7zip/Common/InOutTempBuffer.cpp
+++ b/CPP/7zip/Common/InOutTempBuffer.cpp
@@ -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;
}
+*/