• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
64   bool YesToAll;
65   bool ShowDialog;
66   bool TechMode;
67   bool ShowTime;
68   CBoolPair ListPathSeparatorSlash;
69 
70   CBoolPair NtSecurity;
71   CBoolPair AltStreams;
72   CBoolPair HardLinks;
73   CBoolPair SymLinks;
74 
75   CBoolPair StoreOwnerId;
76   CBoolPair StoreOwnerName;
77 
78   AString ListFields;
79 
80   int ConsoleCodePage;
81 
82   NWildcard::CCensor Censor;
83 
84   CArcCommand Command;
85   UString ArchiveName;
86 
87   #ifndef Z7_NO_CRYPTO
88   bool PasswordEnabled;
89   UString Password;
90   #endif
91 
92   UStringVector HashMethods;
93   // UString HashFilePath;
94 
95   // bool AppendName;
96   // UStringVector ArchivePathsSorted;
97   // UStringVector ArchivePathsFullSorted;
98   NWildcard::CCensor arcCensor;
99   UString ArcName_for_StdInMode;
100 
101   CObjectVector<CProperty> Properties;
102 
103   CExtractOptionsBase ExtractOptions;
104 
105   CUpdateOptions UpdateOptions;
106   CHashOptions HashOptions;
107   UString ArcType;
108   UStringVector ExcludedArcTypes;
109 
110   unsigned Number_for_Out;
111   unsigned Number_for_Errors;
112   unsigned Number_for_Percents;
113   unsigned LogLevel;
114 
115   // bool IsOutAllowed() const { return Number_for_Out != k_OutStream_disabled; }
116 
117   // Benchmark
118   UInt32 NumIterations;
119   bool NumIterations_Defined;
120 
CArcCmdLineOptionsCArcCmdLineOptions121   CArcCmdLineOptions():
122       HelpMode(false),
123       // LargePages(false),
124       CaseSensitive_Change(false),
125       CaseSensitive(false),
126 
127       IsInTerminal(false),
128       IsStdOutTerminal(false),
129       IsStdErrTerminal(false),
130 
131       StdInMode(false),
132       StdOutMode(false),
133 
134       EnableHeaders(false),
135 
136       YesToAll(false),
137       ShowDialog(false),
138       TechMode(false),
139       ShowTime(false),
140 
141       ConsoleCodePage(-1),
142 
143       Number_for_Out(k_OutStream_stdout),
144       Number_for_Errors(k_OutStream_stderr),
145       Number_for_Percents(k_OutStream_stdout),
146 
147       LogLevel(0)
148   {
149     ListPathSeparatorSlash.Val =
150 #ifdef _WIN32
151         false;
152 #else
153         true;
154 #endif
155   }
156 };
157 
158 class CArcCmdLineParser
159 {
160   NCommandLineParser::CParser parser;
161 public:
162   UString Parse1Log;
163   void Parse1(const UStringVector &commandStrings, CArcCmdLineOptions &options);
164   void Parse2(CArcCmdLineOptions &options);
165 };
166 
167 #endif
168