1 // 7zFolderOutStream.h
2 
3 #ifndef __7Z_FOLDER_OUT_STREAM_H
4 #define __7Z_FOLDER_OUT_STREAM_H
5 
6 #include "../../IStream.h"
7 #include "../IArchive.h"
8 #include "../Common/OutStreamWithCRC.h"
9 
10 #include "7zIn.h"
11 
12 namespace NArchive {
13 namespace N7z {
14 
15 class CFolderOutStream:
16   public ISequentialOutStream,
17   public ICompressGetSubStreamSize,
18   public CMyUnknownImp
19 {
20   COutStreamWithCRC *_crcStreamSpec;
21   CMyComPtr<ISequentialOutStream> _crcStream;
22   const CArchiveDatabaseEx *_db;
23   const CBoolVector *_extractStatuses;
24   CMyComPtr<IArchiveExtractCallback> _extractCallback;
25   UInt32 _ref2Offset;
26   UInt32 _startIndex;
27   int _currentIndex;
28   bool _testMode;
29   bool _checkCrc;
30   bool _fileIsOpen;
31   UInt64 _rem;
32 
33   HRESULT OpenFile();
34   HRESULT CloseFileAndSetResult(Int32 res);
35   HRESULT CloseFileAndSetResult();
36   HRESULT ProcessEmptyFiles();
37 public:
38   MY_UNKNOWN_IMP1(ICompressGetSubStreamSize)
39 
40   CFolderOutStream();
41 
42   STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
43   STDMETHOD(GetSubStreamSize)(UInt64 subStream, UInt64 *value);
44 
45   HRESULT Init(
46       const CArchiveDatabaseEx *db,
47       UInt32 ref2Offset, UInt32 startIndex,
48       const CBoolVector *extractStatuses,
49       IArchiveExtractCallback *extractCallback,
50       bool testMode, bool checkCrc);
51   HRESULT FlushCorrupted(Int32 resultEOperationResult);
WasWritingFinished()52   HRESULT WasWritingFinished() const
53       { return (_currentIndex == _extractStatuses->Size()) ? S_OK: E_FAIL; }
54 };
55 
56 }}
57 
58 #endif
59