Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | // Util/InOutTempBuffer.h |
michael@0 | 2 | |
michael@0 | 3 | #ifndef __IN_OUT_TEMP_BUFFER_H |
michael@0 | 4 | #define __IN_OUT_TEMP_BUFFER_H |
michael@0 | 5 | |
michael@0 | 6 | #include "../../Windows/FileIO.h" |
michael@0 | 7 | #include "../../Windows/FileDir.h" |
michael@0 | 8 | #include "../../Common/MyCom.h" |
michael@0 | 9 | |
michael@0 | 10 | #include "../IStream.h" |
michael@0 | 11 | |
michael@0 | 12 | class CInOutTempBuffer |
michael@0 | 13 | { |
michael@0 | 14 | NWindows::NFile::NDirectory::CTempFile _tempFile; |
michael@0 | 15 | NWindows::NFile::NIO::COutFile _outFile; |
michael@0 | 16 | NWindows::NFile::NIO::CInFile _inFile; |
michael@0 | 17 | Byte *_buffer; |
michael@0 | 18 | UInt32 _bufferPosition; |
michael@0 | 19 | UInt32 _currentPositionInBuffer; |
michael@0 | 20 | CSysString _tmpFileName; |
michael@0 | 21 | bool _tmpFileCreated; |
michael@0 | 22 | |
michael@0 | 23 | UInt64 _fileSize; |
michael@0 | 24 | |
michael@0 | 25 | bool WriteToFile(const void *data, UInt32 size); |
michael@0 | 26 | public: |
michael@0 | 27 | CInOutTempBuffer(); |
michael@0 | 28 | ~CInOutTempBuffer(); |
michael@0 | 29 | void Create(); |
michael@0 | 30 | |
michael@0 | 31 | void InitWriting(); |
michael@0 | 32 | bool Write(const void *data, UInt32 size); |
michael@0 | 33 | UInt64 GetDataSize() const { return _fileSize; } |
michael@0 | 34 | bool FlushWrite(); |
michael@0 | 35 | bool InitReading(); |
michael@0 | 36 | HRESULT WriteToStream(ISequentialOutStream *stream); |
michael@0 | 37 | }; |
michael@0 | 38 | |
michael@0 | 39 | class CSequentialOutTempBufferImp: |
michael@0 | 40 | public ISequentialOutStream, |
michael@0 | 41 | public CMyUnknownImp |
michael@0 | 42 | { |
michael@0 | 43 | CInOutTempBuffer *_buffer; |
michael@0 | 44 | public: |
michael@0 | 45 | // CSequentialOutStreamImp(): _size(0) {} |
michael@0 | 46 | // UInt32 _size; |
michael@0 | 47 | void Init(CInOutTempBuffer *buffer) { _buffer = buffer; } |
michael@0 | 48 | // UInt32 GetSize() const { return _size; } |
michael@0 | 49 | |
michael@0 | 50 | MY_UNKNOWN_IMP |
michael@0 | 51 | |
michael@0 | 52 | STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize); |
michael@0 | 53 | }; |
michael@0 | 54 | |
michael@0 | 55 | #endif |