summaryrefslogtreecommitdiffstats
path: root/src/libs/7zip/unix/CPP/7zip/Common/StreamBinder.cpp
diff options
context:
space:
mode:
authorArttu Tarkiainen <arttu.tarkiainen@qt.io>2022-04-06 13:33:38 +0300
committerArttu Tarkiainen <arttu.tarkiainen@qt.io>2022-04-13 11:32:09 +0300
commit96ade47c182bf37a2efca2aa62922e54e5ff1660 (patch)
tree93ceee6c6f8984f563f3dfe83e56f98b66b40f3a /src/libs/7zip/unix/CPP/7zip/Common/StreamBinder.cpp
parent2d5f0ffaf1278516bbd74e3b60f9849f4c51cffa (diff)
Move LZMA SDK to 3rdparty subdirectory
Also add attribution document. Task-number: QTIFW-2336 Change-Id: I91546bc6c3ace244e4b546b945f40b7d204f7463 Reviewed-by: Katja Marttila <katja.marttila@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'src/libs/7zip/unix/CPP/7zip/Common/StreamBinder.cpp')
-rw-r--r--src/libs/7zip/unix/CPP/7zip/Common/StreamBinder.cpp129
1 files changed, 0 insertions, 129 deletions
diff --git a/src/libs/7zip/unix/CPP/7zip/Common/StreamBinder.cpp b/src/libs/7zip/unix/CPP/7zip/Common/StreamBinder.cpp
deleted file mode 100644
index 43feef1ba..000000000
--- a/src/libs/7zip/unix/CPP/7zip/Common/StreamBinder.cpp
+++ /dev/null
@@ -1,129 +0,0 @@
-// StreamBinder.cpp
-
-#include "StdAfx.h"
-
-#include "../../Common/MyCom.h"
-
-#include "StreamBinder.h"
-
-class CBinderInStream:
- public ISequentialInStream,
- public CMyUnknownImp
-{
- CStreamBinder *_binder;
-public:
- MY_UNKNOWN_IMP
- STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
- ~CBinderInStream() { _binder->CloseRead(); }
- CBinderInStream(CStreamBinder *binder): _binder(binder) {}
-};
-
-STDMETHODIMP CBinderInStream::Read(void *data, UInt32 size, UInt32 *processedSize)
- { return _binder->Read(data, size, processedSize); }
-
-class CBinderOutStream:
- public ISequentialOutStream,
- public CMyUnknownImp
-{
- CStreamBinder *_binder;
-public:
- MY_UNKNOWN_IMP
- STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
- ~CBinderOutStream() { _binder->CloseWrite(); }
- CBinderOutStream(CStreamBinder *binder): _binder(binder) {}
-};
-
-STDMETHODIMP CBinderOutStream::Write(const void *data, UInt32 size, UInt32 *processedSize)
- { return _binder->Write(data, size, processedSize); }
-
-
-
-WRes CStreamBinder::CreateEvents()
-{
- _synchroFor_canWrite_Event_and_readingWasClosed_Event = new NWindows::NSynchronization::CSynchro();
- _synchroFor_canWrite_Event_and_readingWasClosed_Event->Create();
- RINOK(_canWrite_Event.Create(_synchroFor_canWrite_Event_and_readingWasClosed_Event,true));
- // RINOK(_canWrite_Event.Create(true));
- RINOK(_canRead_Event.Create());
- return _readingWasClosed_Event.Create(_synchroFor_canWrite_Event_and_readingWasClosed_Event);
-}
-
-void CStreamBinder::ReInit()
-{
- _waitWrite = true;
- _canRead_Event.Reset();
- _readingWasClosed_Event.Reset();
- ProcessedSize = 0;
-}
-
-
-void CStreamBinder::CreateStreams(ISequentialInStream **inStream, ISequentialOutStream **outStream)
-{
- _waitWrite = true;
- _bufSize = 0;
- _buf = NULL;
- ProcessedSize = 0;
-
- CBinderInStream *inStreamSpec = new CBinderInStream(this);
- CMyComPtr<ISequentialInStream> inStreamLoc(inStreamSpec);
- *inStream = inStreamLoc.Detach();
-
- CBinderOutStream *outStreamSpec = new CBinderOutStream(this);
- CMyComPtr<ISequentialOutStream> outStreamLoc(outStreamSpec);
- *outStream = outStreamLoc.Detach();
-}
-
-// (_canRead_Event && _bufSize == 0) means that stream is finished.
-
-HRESULT CStreamBinder::Read(void *data, UInt32 size, UInt32 *processedSize)
-{
- if (processedSize)
- *processedSize = 0;
- if (size != 0)
- {
- if (_waitWrite)
- {
- RINOK(_canRead_Event.Lock());
- _waitWrite = false;
- }
- if (size > _bufSize)
- size = _bufSize;
- if (size != 0)
- {
- memcpy(data, _buf, size);
- _buf = ((const Byte *)_buf) + size;
- ProcessedSize += size;
- if (processedSize)
- *processedSize = size;
- _bufSize -= size;
- if (_bufSize == 0)
- {
- _waitWrite = true;
- _canRead_Event.Reset();
- _canWrite_Event.Set();
- }
- }
- }
- return S_OK;
-}
-
-HRESULT CStreamBinder::Write(const void *data, UInt32 size, UInt32 *processedSize)
-{
- if (processedSize)
- *processedSize = 0;
- if (size != 0)
- {
- _buf = data;
- _bufSize = size;
- _canWrite_Event.Reset();
- _canRead_Event.Set();
-
- HANDLE events[2] = { _canWrite_Event, _readingWasClosed_Event };
- DWORD waitResult = ::WaitForMultipleObjects(2, events, FALSE, INFINITE);
- if (waitResult != WAIT_OBJECT_0 + 0)
- return S_FALSE;
- if (processedSize)
- *processedSize = size;
- }
- return S_OK;
-}