summaryrefslogtreecommitdiffstats
path: root/CPP/7zip/Archive/7z/7zFolderOutStream.h
blob: c964b1d49d36f47517d451638d6642e4855d08bd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// 7zFolderOutStream.h

#ifndef __7Z_FOLDER_OUT_STREAM_H
#define __7Z_FOLDER_OUT_STREAM_H

#include "../../IStream.h"
#include "../IArchive.h"
#include "../Common/OutStreamWithCRC.h"

#include "7zIn.h"

namespace NArchive {
namespace N7z {

class CFolderOutStream:
  public ISequentialOutStream,
  public ICompressGetSubStreamSize,
  public CMyUnknownImp
{
  COutStreamWithCRC *_crcStreamSpec;
  CMyComPtr<ISequentialOutStream> _crcStream;
  const CArchiveDatabaseEx *_db;
  const CBoolVector *_extractStatuses;
  CMyComPtr<IArchiveExtractCallback> _extractCallback;
  UInt32 _ref2Offset;
  UInt32 _startIndex;
  int _currentIndex;
  bool _testMode;
  bool _checkCrc;
  bool _fileIsOpen;
  UInt64 _rem;

  HRESULT OpenFile();
  HRESULT CloseFileAndSetResult(Int32 res);
  HRESULT CloseFileAndSetResult();
  HRESULT ProcessEmptyFiles();
public:
  MY_UNKNOWN_IMP1(ICompressGetSubStreamSize)

  CFolderOutStream();

  STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
  STDMETHOD(GetSubStreamSize)(UInt64 subStream, UInt64 *value);

  HRESULT Init(
      const CArchiveDatabaseEx *db,
      UInt32 ref2Offset, UInt32 startIndex,
      const CBoolVector *extractStatuses,
      IArchiveExtractCallback *extractCallback,
      bool testMode, bool checkCrc);
  HRESULT FlushCorrupted(Int32 resultEOperationResult);
  HRESULT WasWritingFinished() const
      { return (_currentIndex == _extractStatuses->Size()) ? S_OK: E_FAIL; }
};

}}

#endif