1 // ExtractCallbackConsole.h 2 3 #ifndef ZIP7_INC_EXTRACT_CALLBACK_CONSOLE_H 4 #define ZIP7_INC_EXTRACT_CALLBACK_CONSOLE_H 5 6 #include "../../../Common/StdOutStream.h" 7 8 #include "../../IPassword.h" 9 10 #include "../../Archive/IArchive.h" 11 12 #include "../Common/ArchiveExtractCallback.h" 13 14 #include "PercentPrinter.h" 15 16 #include "OpenCallbackConsole.h" 17 18 /* 19 struct CErrorPathCodes2 20 { 21 FStringVector Paths; 22 CRecordVector<DWORD> Codes; 23 24 void AddError(const FString &path, DWORD systemError) 25 { 26 Paths.Add(path); 27 Codes.Add(systemError); 28 } 29 void Clear() 30 { 31 Paths.Clear(); 32 Codes.Clear(); 33 } 34 }; 35 */ 36 37 class CExtractScanConsole Z7_final: public IDirItemsCallback 38 { 39 Z7_IFACE_IMP(IDirItemsCallback) 40 41 CStdOutStream *_so; 42 CStdOutStream *_se; 43 CPercentPrinter _percent; 44 45 // CErrorPathCodes2 ScanErrors; 46 NeedPercents()47 bool NeedPercents() const { return _percent._so && !_percent.DisablePrint; } 48 ClosePercentsAndFlush()49 void ClosePercentsAndFlush() 50 { 51 if (NeedPercents()) 52 _percent.ClosePrint(true); 53 if (_so) 54 _so->Flush(); 55 } 56 57 public: 58 Init(CStdOutStream * outStream,CStdOutStream * errorStream,CStdOutStream * percentStream,bool disablePercents)59 void Init( 60 CStdOutStream *outStream, 61 CStdOutStream *errorStream, 62 CStdOutStream *percentStream, 63 bool disablePercents) 64 { 65 _so = outStream; 66 _se = errorStream; 67 _percent._so = percentStream; 68 _percent.DisablePrint = disablePercents; 69 } 70 SetWindowWidth(unsigned width)71 void SetWindowWidth(unsigned width) { _percent.MaxLen = width - 1; } 72 73 void StartScanning(); 74 CloseScanning()75 void CloseScanning() 76 { 77 if (NeedPercents()) 78 _percent.ClosePrint(true); 79 } 80 81 void PrintStat(const CDirItemsStat &st); 82 }; 83 84 85 86 87 class CExtractCallbackConsole Z7_final: 88 public IFolderArchiveExtractCallback, 89 public IExtractCallbackUI, 90 // public IArchiveExtractCallbackMessage, 91 public IFolderArchiveExtractCallback2, 92 #ifndef Z7_NO_CRYPTO 93 public ICryptoGetTextPassword, 94 #endif 95 #ifndef Z7_SFX 96 public IArchiveRequestMemoryUseCallback, 97 #endif 98 99 public COpenCallbackConsole, 100 public CMyUnknownImp 101 { 102 Z7_COM_QI_BEGIN2(IFolderArchiveExtractCallback) 103 // Z7_COM_QI_ENTRY(IArchiveExtractCallbackMessage) 104 Z7_COM_QI_ENTRY(IFolderArchiveExtractCallback2) 105 #ifndef Z7_NO_CRYPTO 106 Z7_COM_QI_ENTRY(ICryptoGetTextPassword) 107 #endif 108 #ifndef Z7_SFX 109 Z7_COM_QI_ENTRY(IArchiveRequestMemoryUseCallback) 110 #endif 111 112 Z7_COM_QI_END 113 Z7_COM_ADDREF_RELEASE 114 115 Z7_IFACE_COM7_IMP(IProgress) 116 Z7_IFACE_COM7_IMP(IFolderArchiveExtractCallback) 117 Z7_IFACE_IMP(IExtractCallbackUI) 118 // Z7_IFACE_COM7_IMP(IArchiveExtractCallbackMessage) 119 Z7_IFACE_COM7_IMP(IFolderArchiveExtractCallback2) 120 #ifndef Z7_NO_CRYPTO 121 Z7_IFACE_COM7_IMP(ICryptoGetTextPassword) 122 #endif 123 #ifndef Z7_SFX 124 Z7_IFACE_COM7_IMP(IArchiveRequestMemoryUseCallback) 125 #endif 126 127 bool _needWriteArchivePath; 128 129 public: 130 bool ThereIsError_in_Current; 131 bool ThereIsWarning_in_Current; 132 bool NeedFlush; 133 134 private: 135 AString _tempA; 136 UString _tempU; 137 138 UString _currentArchivePath; 139 UString _currentName; 140 141 #ifndef Z7_SFX 142 void PrintTo_se_Path_WithTitle(const UString &path, const char *title); 143 void Add_ArchiveName_Error(); 144 #endif 145 ClosePercents_for_so()146 void ClosePercents_for_so() 147 { 148 if (NeedPercents() && _so == _percent._so) 149 _percent.ClosePrint(false); 150 } 151 ClosePercentsAndFlush()152 void ClosePercentsAndFlush() 153 { 154 if (NeedPercents()) 155 _percent.ClosePrint(true); 156 if (_so) 157 _so->Flush(); 158 } 159 public: 160 UInt64 NumTryArcs; 161 162 UInt64 NumOkArcs; 163 UInt64 NumCantOpenArcs; 164 UInt64 NumArcsWithError; 165 UInt64 NumArcsWithWarnings; 166 167 UInt64 NumOpenArcErrors; 168 UInt64 NumOpenArcWarnings; 169 170 UInt64 NumFileErrors; 171 UInt64 NumFileErrors_in_Current; 172 173 unsigned PercentsNameLevel; 174 unsigned LogLevel; 175 CExtractCallbackConsole()176 CExtractCallbackConsole(): 177 _needWriteArchivePath(true), 178 NeedFlush(false), 179 PercentsNameLevel(1), 180 LogLevel(0) 181 {} 182 SetWindowWidth(unsigned width)183 void SetWindowWidth(unsigned width) { _percent.MaxLen = width - 1; } 184 Init(CStdOutStream * outStream,CStdOutStream * errorStream,CStdOutStream * percentStream,bool disablePercents)185 void Init( 186 CStdOutStream *outStream, 187 CStdOutStream *errorStream, 188 CStdOutStream *percentStream, 189 bool disablePercents) 190 { 191 COpenCallbackConsole::Init(outStream, errorStream, percentStream, disablePercents); 192 193 NumTryArcs = 0; 194 195 ThereIsError_in_Current = false; 196 ThereIsWarning_in_Current = false; 197 198 NumOkArcs = 0; 199 NumCantOpenArcs = 0; 200 NumArcsWithError = 0; 201 NumArcsWithWarnings = 0; 202 203 NumOpenArcErrors = 0; 204 NumOpenArcWarnings = 0; 205 206 NumFileErrors = 0; 207 NumFileErrors_in_Current = 0; 208 } 209 }; 210 211 #endif 212