• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // ArchiveExtractCallback.h
2 
3 #ifndef __ARCHIVE_EXTRACT_CALLBACK_H
4 #define __ARCHIVE_EXTRACT_CALLBACK_H
5 
6 #include "Common/MyCom.h"
7 #include "Common/Wildcard.h"
8 
9 #include "../../IPassword.h"
10 
11 #include "../../Common/FileStreams.h"
12 #include "../../Common/ProgressUtils.h"
13 
14 #include "../../Archive/IArchive.h"
15 
16 #include "../../Archive/Common/OutStreamWithCRC.h"
17 
18 #include "ExtractMode.h"
19 #include "IFileExtractCallback.h"
20 #include "OpenArchive.h"
21 
22 class CArchiveExtractCallback:
23   public IArchiveExtractCallback,
24   // public IArchiveVolumeExtractCallback,
25   public ICryptoGetTextPassword,
26   public ICompressProgressInfo,
27   public CMyUnknownImp
28 {
29   const CArc *_arc;
30   const NWildcard::CCensorNode *_wildcardCensor;
31   CMyComPtr<IFolderArchiveExtractCallback> _extractCallback2;
32   CMyComPtr<ICompressProgressInfo> _compressProgress;
33   CMyComPtr<ICryptoGetTextPassword> _cryptoGetTextPassword;
34   UString _directoryPath;
35   NExtract::NPathMode::EEnum _pathMode;
36   NExtract::NOverwriteMode::EEnum _overwriteMode;
37 
38   UString _diskFilePath;
39   UString _filePath;
40   UInt64 _position;
41   bool _isSplit;
42 
43   bool _extractMode;
44 
45   bool WriteCTime;
46   bool WriteATime;
47   bool WriteMTime;
48 
49   bool _encrypted;
50 
51   struct CProcessedFileInfo
52   {
53     FILETIME CTime;
54     FILETIME ATime;
55     FILETIME MTime;
56     UInt32 Attrib;
57 
58     bool CTimeDefined;
59     bool ATimeDefined;
60     bool MTimeDefined;
61     bool AttribDefined;
62 
63     bool IsDir;
64   } _fi;
65 
66   UInt32 _index;
67   UInt64 _curSize;
68   bool _curSizeDefined;
69   COutFileStream *_outFileStreamSpec;
70   CMyComPtr<ISequentialOutStream> _outFileStream;
71 
72   COutStreamWithCRC *_crcStreamSpec;
73   CMyComPtr<ISequentialOutStream> _crcStream;
74 
75   UStringVector _removePathParts;
76 
77   bool _stdOutMode;
78   bool _testMode;
79   bool _crcMode;
80   bool _multiArchives;
81 
82   CMyComPtr<ICompressProgressInfo> _localProgress;
83   UInt64 _packTotal;
84   UInt64 _unpTotal;
85 
86   void CreateComplexDirectory(const UStringVector &dirPathParts, UString &fullPath);
87   HRESULT GetTime(int index, PROPID propID, FILETIME &filetime, bool &filetimeIsDefined);
88   HRESULT GetUnpackSize();
89 
90 public:
91 
92   CLocalProgress *LocalProgressSpec;
93 
94   UInt64 NumFolders;
95   UInt64 NumFiles;
96   UInt64 UnpackSize;
97   UInt32 CrcSum;
98 
99   MY_UNKNOWN_IMP2(ICryptoGetTextPassword, ICompressProgressInfo)
100   // COM_INTERFACE_ENTRY(IArchiveVolumeExtractCallback)
101 
102   INTERFACE_IArchiveExtractCallback(;)
103 
104   STDMETHOD(SetRatioInfo)(const UInt64 *inSize, const UInt64 *outSize);
105 
106   // IArchiveVolumeExtractCallback
107   // STDMETHOD(GetInStream)(const wchar_t *name, ISequentialInStream **inStream);
108 
109   STDMETHOD(CryptoGetTextPassword)(BSTR *password);
110 
CArchiveExtractCallback()111   CArchiveExtractCallback():
112       WriteCTime(true),
113       WriteATime(true),
114       WriteMTime(true),
115       _multiArchives(false)
116   {
117     LocalProgressSpec = new CLocalProgress();
118     _localProgress = LocalProgressSpec;
119   }
120 
InitForMulti(bool multiArchives,NExtract::NPathMode::EEnum pathMode,NExtract::NOverwriteMode::EEnum overwriteMode)121   void InitForMulti(bool multiArchives,
122       NExtract::NPathMode::EEnum pathMode,
123       NExtract::NOverwriteMode::EEnum overwriteMode)
124   {
125     _multiArchives = multiArchives;
126     _pathMode = pathMode;
127     _overwriteMode = overwriteMode;
128     NumFolders = NumFiles = UnpackSize = 0;
129     CrcSum = 0;
130   }
131 
132   void Init(
133       const NWildcard::CCensorNode *wildcardCensor,
134       const CArc *arc,
135       IFolderArchiveExtractCallback *extractCallback2,
136       bool stdOutMode, bool testMode, bool crcMode,
137       const UString &directoryPath,
138       const UStringVector &removePathParts,
139       UInt64 packSize);
140 
141 };
142 
143 #endif
144