xref: /aosp_15_r20/external/lzma/CPP/7zip/UI/Common/ArchiveCommandLine.h (revision f6dc9357d832569d4d1f5d24eacdb3935a1ae8e6)
1 // ArchiveCommandLine.h
2 
3 #ifndef ZIP7_INC_ARCHIVE_COMMAND_LINE_H
4 #define ZIP7_INC_ARCHIVE_COMMAND_LINE_H
5 
6 #include "../../../Common/CommandLineParser.h"
7 #include "../../../Common/Wildcard.h"
8 
9 #include "EnumDirItems.h"
10 
11 #include "Extract.h"
12 #include "HashCalc.h"
13 #include "Update.h"
14 
15 typedef CMessagePathException CArcCmdLineException;
16 
17 namespace NCommandType { enum EEnum
18 {
19   kAdd = 0,
20   kUpdate,
21   kDelete,
22   kTest,
23   kExtract,
24   kExtractFull,
25   kList,
26   kBenchmark,
27   kInfo,
28   kHash,
29   kRename
30 };}
31 
32 struct CArcCommand
33 {
34   NCommandType::EEnum CommandType;
35 
36   bool IsFromExtractGroup() const;
37   bool IsFromUpdateGroup() const;
IsTestCommandCArcCommand38   bool IsTestCommand() const { return CommandType == NCommandType::kTest; }
39   NExtract::NPathMode::EEnum GetPathMode() const;
40 };
41 
42 enum
43 {
44   k_OutStream_disabled = 0,
45   k_OutStream_stdout = 1,
46   k_OutStream_stderr = 2
47 };
48 
49 struct CArcCmdLineOptions
50 {
51   bool HelpMode;
52 
53   // bool LargePages;
54   bool CaseSensitive_Change;
55   bool CaseSensitive;
56 
57   bool IsInTerminal;
58   bool IsStdOutTerminal;
59   bool IsStdErrTerminal;
60   bool StdInMode;
61   bool StdOutMode;
62   bool EnableHeaders;
63   bool DisablePercents;
64 
65 
66   bool YesToAll;
67   bool ShowDialog;
68   bool TechMode;
69   bool ShowTime;
70   CBoolPair ListPathSeparatorSlash;
71 
72   CBoolPair NtSecurity;
73   CBoolPair AltStreams;
74   CBoolPair HardLinks;
75   CBoolPair SymLinks;
76 
77   CBoolPair StoreOwnerId;
78   CBoolPair StoreOwnerName;
79 
80   AString ListFields;
81 
82   int ConsoleCodePage;
83 
84   NWildcard::CCensor Censor;
85 
86   CArcCommand Command;
87   UString ArchiveName;
88 
89   #ifndef Z7_NO_CRYPTO
90   bool PasswordEnabled;
91   UString Password;
92   #endif
93 
94   UStringVector HashMethods;
95   // UString HashFilePath;
96 
97   // bool AppendName;
98   // UStringVector ArchivePathsSorted;
99   // UStringVector ArchivePathsFullSorted;
100   NWildcard::CCensor arcCensor;
101   UString ArcName_for_StdInMode;
102 
103   CObjectVector<CProperty> Properties;
104 
105   CExtractOptionsBase ExtractOptions;
106 
107   CUpdateOptions UpdateOptions;
108   CHashOptions HashOptions;
109   UString ArcType;
110   UStringVector ExcludedArcTypes;
111 
112   unsigned Number_for_Out;
113   unsigned Number_for_Errors;
114   unsigned Number_for_Percents;
115   unsigned LogLevel;
116 
117   // bool IsOutAllowed() const { return Number_for_Out != k_OutStream_disabled; }
118 
119   // Benchmark
120   UInt32 NumIterations;
121   bool NumIterations_Defined;
122 
CArcCmdLineOptionsCArcCmdLineOptions123   CArcCmdLineOptions():
124       HelpMode(false),
125       // LargePages(false),
126       CaseSensitive_Change(false),
127       CaseSensitive(false),
128 
129       IsInTerminal(false),
130       IsStdOutTerminal(false),
131       IsStdErrTerminal(false),
132 
133       StdInMode(false),
134       StdOutMode(false),
135 
136       EnableHeaders(false),
137       DisablePercents(false),
138 
139       YesToAll(false),
140       ShowDialog(false),
141       TechMode(false),
142       ShowTime(false),
143 
144       ConsoleCodePage(-1),
145 
146       Number_for_Out(k_OutStream_stdout),
147       Number_for_Errors(k_OutStream_stderr),
148       Number_for_Percents(k_OutStream_stdout),
149 
150       LogLevel(0)
151   {
152     ListPathSeparatorSlash.Val =
153 #ifdef _WIN32
154         false;
155 #else
156         true;
157 #endif
158   }
159 };
160 
161 class CArcCmdLineParser
162 {
163   NCommandLineParser::CParser parser;
164 public:
165   UString Parse1Log;
166   void Parse1(const UStringVector &commandStrings, CArcCmdLineOptions &options);
167   void Parse2(CArcCmdLineOptions &options);
168 };
169 
170 #endif
171