• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // ExtractCallbackConsole.h
2 
3 #ifndef __EXTRACT_CALLBACK_CONSOLE_H
4 #define __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 class CExtractScanConsole: public IDirItemsCallback
19 {
20   CStdOutStream *_so;
21   CStdOutStream *_se;
22   CPercentPrinter _percent;
23 
NeedPercents()24   bool NeedPercents() const { return _percent._so != NULL; }
25 
ClosePercentsAndFlush()26   void ClosePercentsAndFlush()
27   {
28     if (NeedPercents())
29       _percent.ClosePrint(true);
30     if (_so)
31       _so->Flush();
32   }
33 
34 public:
Init(CStdOutStream * outStream,CStdOutStream * errorStream,CStdOutStream * percentStream)35   void Init(CStdOutStream *outStream, CStdOutStream *errorStream, CStdOutStream *percentStream)
36   {
37     _so = outStream;
38     _se = errorStream;
39     _percent._so = percentStream;
40   }
41 
SetWindowWidth(unsigned width)42   void SetWindowWidth(unsigned width) { _percent.MaxLen = width - 1; }
43 
44   void StartScanning();
45 
46   INTERFACE_IDirItemsCallback(;)
47 
CloseScanning()48   void CloseScanning()
49   {
50     if (NeedPercents())
51       _percent.ClosePrint(true);
52   }
53 
54   void PrintStat(const CDirItemsStat &st);
55 };
56 
57 
58 
59 
60 class CExtractCallbackConsole:
61   public IExtractCallbackUI,
62   // public IArchiveExtractCallbackMessage,
63   public IFolderArchiveExtractCallback2,
64   #ifndef _NO_CRYPTO
65   public ICryptoGetTextPassword,
66   #endif
67   public COpenCallbackConsole,
68   public CMyUnknownImp
69 {
70   AString _tempA;
71   UString _tempU;
72 
73   UString _currentName;
74 
ClosePercents_for_so()75   void ClosePercents_for_so()
76   {
77     if (NeedPercents() && _so == _percent._so)
78       _percent.ClosePrint(false);
79   }
80 
ClosePercentsAndFlush()81   void ClosePercentsAndFlush()
82   {
83     if (NeedPercents())
84       _percent.ClosePrint(true);
85     if (_so)
86       _so->Flush();
87   }
88 
89 public:
90   MY_QUERYINTERFACE_BEGIN2(IFolderArchiveExtractCallback)
91   // MY_QUERYINTERFACE_ENTRY(IArchiveExtractCallbackMessage)
92   MY_QUERYINTERFACE_ENTRY(IFolderArchiveExtractCallback2)
93   #ifndef _NO_CRYPTO
94   MY_QUERYINTERFACE_ENTRY(ICryptoGetTextPassword)
95   #endif
96   MY_QUERYINTERFACE_END
97   MY_ADDREF_RELEASE
98 
99   STDMETHOD(SetTotal)(UInt64 total);
100   STDMETHOD(SetCompleted)(const UInt64 *completeValue);
101 
102   INTERFACE_IFolderArchiveExtractCallback(;)
103 
104   INTERFACE_IExtractCallbackUI(;)
105   // INTERFACE_IArchiveExtractCallbackMessage(;)
106   INTERFACE_IFolderArchiveExtractCallback2(;)
107 
108   #ifndef _NO_CRYPTO
109 
110   STDMETHOD(CryptoGetTextPassword)(BSTR *password);
111 
112   #endif
113 
114   UInt64 NumTryArcs;
115 
116   bool ThereIsError_in_Current;
117   bool ThereIsWarning_in_Current;
118 
119   UInt64 NumOkArcs;
120   UInt64 NumCantOpenArcs;
121   UInt64 NumArcsWithError;
122   UInt64 NumArcsWithWarnings;
123 
124   UInt64 NumOpenArcErrors;
125   UInt64 NumOpenArcWarnings;
126 
127   UInt64 NumFileErrors;
128   UInt64 NumFileErrors_in_Current;
129 
130   bool NeedFlush;
131   unsigned PercentsNameLevel;
132   unsigned LogLevel;
133 
CExtractCallbackConsole()134   CExtractCallbackConsole():
135       NeedFlush(false),
136       PercentsNameLevel(1),
137       LogLevel(0)
138       {}
139 
SetWindowWidth(unsigned width)140   void SetWindowWidth(unsigned width) { _percent.MaxLen = width - 1; }
141 
Init(CStdOutStream * outStream,CStdOutStream * errorStream,CStdOutStream * percentStream)142   void Init(CStdOutStream *outStream, CStdOutStream *errorStream, CStdOutStream *percentStream)
143   {
144     COpenCallbackConsole::Init(outStream, errorStream, percentStream);
145 
146     NumTryArcs = 0;
147 
148     ThereIsError_in_Current = false;
149     ThereIsWarning_in_Current = false;
150 
151     NumOkArcs = 0;
152     NumCantOpenArcs = 0;
153     NumArcsWithError = 0;
154     NumArcsWithWarnings = 0;
155 
156     NumOpenArcErrors = 0;
157     NumOpenArcWarnings = 0;
158 
159     NumFileErrors = 0;
160     NumFileErrors_in_Current = 0;
161   }
162 };
163 
164 #endif
165