summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/lzma/CPP/7zip/Common/StreamUtils.cpp
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2023-12-06 07:58:49 +1100
committer Vas Crabb <vas@vastheman.com>2023-12-06 07:58:49 +1100
commit79bef1e23049fdac25f1fefd132e0b6c7d2cc3a1 (patch)
tree643e9313fe86f583c4022c338677cbc12b761df7 /3rdparty/lzma/CPP/7zip/Common/StreamUtils.cpp
parent512ccf0c7c9b4f08e41038b2ed2de220e140385b (diff)
3rdparty/lzma: Updated to version 23.01.
Diffstat (limited to '3rdparty/lzma/CPP/7zip/Common/StreamUtils.cpp')
-rw-r--r--3rdparty/lzma/CPP/7zip/Common/StreamUtils.cpp53
1 files changed, 49 insertions, 4 deletions
diff --git a/3rdparty/lzma/CPP/7zip/Common/StreamUtils.cpp b/3rdparty/lzma/CPP/7zip/Common/StreamUtils.cpp
index 1402f420599..24eed36c5bf 100644
--- a/3rdparty/lzma/CPP/7zip/Common/StreamUtils.cpp
+++ b/3rdparty/lzma/CPP/7zip/Common/StreamUtils.cpp
@@ -2,10 +2,55 @@
#include "StdAfx.h"
+#include "../../Common/MyCom.h"
+
#include "StreamUtils.h"
static const UInt32 kBlockSize = ((UInt32)1 << 31);
+
+HRESULT InStream_SeekToBegin(IInStream *stream) throw()
+{
+ return InStream_SeekSet(stream, 0);
+}
+
+
+HRESULT InStream_AtBegin_GetSize(IInStream *stream, UInt64 &sizeRes) throw()
+{
+#ifdef _WIN32
+ {
+ Z7_DECL_CMyComPtr_QI_FROM(
+ IStreamGetSize,
+ streamGetSize, stream)
+ if (streamGetSize && streamGetSize->GetSize(&sizeRes) == S_OK)
+ return S_OK;
+ }
+#endif
+ const HRESULT hres = InStream_GetSize_SeekToEnd(stream, sizeRes);
+ const HRESULT hres2 = InStream_SeekToBegin(stream);
+ return hres != S_OK ? hres : hres2;
+}
+
+
+HRESULT InStream_GetPos_GetSize(IInStream *stream, UInt64 &curPosRes, UInt64 &sizeRes) throw()
+{
+ RINOK(InStream_GetPos(stream, curPosRes))
+#ifdef _WIN32
+ {
+ Z7_DECL_CMyComPtr_QI_FROM(
+ IStreamGetSize,
+ streamGetSize, stream)
+ if (streamGetSize && streamGetSize->GetSize(&sizeRes) == S_OK)
+ return S_OK;
+ }
+#endif
+ const HRESULT hres = InStream_GetSize_SeekToEnd(stream, sizeRes);
+ const HRESULT hres2 = InStream_SeekSet(stream, curPosRes);
+ return hres != S_OK ? hres : hres2;
+}
+
+
+
HRESULT ReadStream(ISequentialInStream *stream, void *data, size_t *processedSize) throw()
{
size_t size = *processedSize;
@@ -18,7 +63,7 @@ HRESULT ReadStream(ISequentialInStream *stream, void *data, size_t *processedSiz
*processedSize += processedSizeLoc;
data = (void *)((Byte *)data + processedSizeLoc);
size -= processedSizeLoc;
- RINOK(res);
+ RINOK(res)
if (processedSizeLoc == 0)
return S_OK;
}
@@ -28,14 +73,14 @@ HRESULT ReadStream(ISequentialInStream *stream, void *data, size_t *processedSiz
HRESULT ReadStream_FALSE(ISequentialInStream *stream, void *data, size_t size) throw()
{
size_t processedSize = size;
- RINOK(ReadStream(stream, data, &processedSize));
+ RINOK(ReadStream(stream, data, &processedSize))
return (size == processedSize) ? S_OK : S_FALSE;
}
HRESULT ReadStream_FAIL(ISequentialInStream *stream, void *data, size_t size) throw()
{
size_t processedSize = size;
- RINOK(ReadStream(stream, data, &processedSize));
+ RINOK(ReadStream(stream, data, &processedSize))
return (size == processedSize) ? S_OK : E_FAIL;
}
@@ -48,7 +93,7 @@ HRESULT WriteStream(ISequentialOutStream *stream, const void *data, size_t size)
HRESULT res = stream->Write(data, curSize, &processedSizeLoc);
data = (const void *)((const Byte *)data + processedSizeLoc);
size -= processedSizeLoc;
- RINOK(res);
+ RINOK(res)
if (processedSizeLoc == 0)
return E_FAIL;
}