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