Mercurial > vba-linux
diff src/win32/7zip/7z/CPP/7zip/Common/OutMemStream.h @ 1:f9f4f1b99eed
importing src directory
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Sat, 03 Mar 2012 10:31:27 -0600 |
parents | |
children |
line wrap: on
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/win32/7zip/7z/CPP/7zip/Common/OutMemStream.h Sat Mar 03 10:31:27 2012 -0600 1.3 @@ -0,0 +1,96 @@ 1.4 +// OutMemStream.h 1.5 + 1.6 +#ifndef __OUTMEMSTREAM_H 1.7 +#define __OUTMEMSTREAM_H 1.8 + 1.9 +#include "Common/MyCom.h" 1.10 +#include "MemBlocks.h" 1.11 + 1.12 +class COutMemStream: 1.13 + public IOutStream, 1.14 + public CMyUnknownImp 1.15 +{ 1.16 + CMemBlockManagerMt *_memManager; 1.17 + size_t _curBlockIndex; 1.18 + size_t _curBlockPos; 1.19 + bool _realStreamMode; 1.20 + 1.21 + bool _unlockEventWasSent; 1.22 + NWindows::NSynchronization::CAutoResetEvent StopWritingEvent; 1.23 + NWindows::NSynchronization::CAutoResetEvent WriteToRealStreamEvent; 1.24 + // NWindows::NSynchronization::CAutoResetEvent NoLockEvent; 1.25 + 1.26 + HRESULT StopWriteResult; 1.27 + CMemLockBlocks Blocks; 1.28 + 1.29 + UInt64 GetPos() const { return (UInt64)_curBlockIndex * _memManager->GetBlockSize() + _curBlockPos; } 1.30 + 1.31 + CMyComPtr<ISequentialOutStream> OutSeqStream; 1.32 + CMyComPtr<IOutStream> OutStream; 1.33 + 1.34 +public: 1.35 + 1.36 + HRes CreateEvents() 1.37 + { 1.38 + RINOK(StopWritingEvent.CreateIfNotCreated()); 1.39 + return WriteToRealStreamEvent.CreateIfNotCreated(); 1.40 + } 1.41 + 1.42 + void SetOutStream(IOutStream *outStream) 1.43 + { 1.44 + OutStream = outStream; 1.45 + OutSeqStream = outStream; 1.46 + } 1.47 + 1.48 + void SetSeqOutStream(ISequentialOutStream *outStream) 1.49 + { 1.50 + OutStream = NULL; 1.51 + OutSeqStream = outStream; 1.52 + } 1.53 + 1.54 + void ReleaseOutStream() 1.55 + { 1.56 + OutStream.Release(); 1.57 + OutSeqStream.Release(); 1.58 + } 1.59 + 1.60 + COutMemStream(CMemBlockManagerMt *memManager): _memManager(memManager) { } 1.61 + 1.62 + ~COutMemStream() { Free(); } 1.63 + void Free(); 1.64 + 1.65 + void Init(); 1.66 + HRESULT WriteToRealStream(); 1.67 + 1.68 + void DetachData(CMemLockBlocks &blocks); 1.69 + 1.70 + bool WasUnlockEventSent() const { return _unlockEventWasSent; } 1.71 + 1.72 + void SetRealStreamMode() 1.73 + { 1.74 + _unlockEventWasSent = true; 1.75 + WriteToRealStreamEvent.Set(); 1.76 + } 1.77 + 1.78 + /* 1.79 + void SetNoLockMode() 1.80 + { 1.81 + _unlockEventWasSent = true; 1.82 + NoLockEvent.Set(); 1.83 + } 1.84 + */ 1.85 + 1.86 + void StopWriting(HRESULT res) 1.87 + { 1.88 + StopWriteResult = res; 1.89 + StopWritingEvent.Set(); 1.90 + } 1.91 + 1.92 + MY_UNKNOWN_IMP 1.93 + 1.94 + STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize); 1.95 + STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition); 1.96 + STDMETHOD(SetSize)(Int64 newSize); 1.97 +}; 1.98 + 1.99 +#endif