xref: /aosp_15_r20/external/lzma/CPP/7zip/UI/Console/OpenCallbackConsole.h (revision f6dc9357d832569d4d1f5d24eacdb3935a1ae8e6)
1 // OpenCallbackConsole.h
2 
3 #ifndef ZIP7_INC_OPEN_CALLBACK_CONSOLE_H
4 #define ZIP7_INC_OPEN_CALLBACK_CONSOLE_H
5 
6 #include "../../../Common/StdOutStream.h"
7 
8 #include "../Common/ArchiveOpenCallback.h"
9 
10 #include "PercentPrinter.h"
11 
12 class COpenCallbackConsole: public IOpenCallbackUI
13 {
14 protected:
15   CPercentPrinter _percent;
16 
17   CStdOutStream *_so;
18   CStdOutStream *_se;
19 
20   // UInt64 _totalFiles;
21   UInt64 _totalBytes;
22   bool _totalFilesDefined;
23   // bool _totalBytesDefined;
24 
NeedPercents()25   bool NeedPercents() const { return _percent._so && !_percent.DisablePrint; }
26 
27 public:
28 
29   bool MultiArcMode;
30 
ClosePercents()31   void ClosePercents()
32   {
33     if (NeedPercents())
34       _percent.ClosePrint(true);
35   }
36 
COpenCallbackConsole()37   COpenCallbackConsole():
38       _totalBytes(0),
39       _totalFilesDefined(false),
40       // _totalBytesDefined(false),
41       MultiArcMode(false)
42 
43       #ifndef Z7_NO_CRYPTO
44       , PasswordIsDefined(false)
45       // , PasswordWasAsked(false)
46       #endif
47 
48       {}
49 
~COpenCallbackConsole()50   virtual ~COpenCallbackConsole() {}
51 
Init(CStdOutStream * outStream,CStdOutStream * errorStream,CStdOutStream * percentStream,bool disablePercents)52   void Init(
53       CStdOutStream *outStream,
54       CStdOutStream *errorStream,
55       CStdOutStream *percentStream,
56       bool disablePercents)
57   {
58     _so = outStream;
59     _se = errorStream;
60     _percent._so = percentStream;
61     _percent.DisablePrint = disablePercents;
62   }
63 
64   Z7_IFACE_IMP(IOpenCallbackUI)
65 
66   #ifndef Z7_NO_CRYPTO
67   bool PasswordIsDefined;
68   // bool PasswordWasAsked;
69   UString Password;
70   #endif
71 };
72 
73 #endif
74