• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // ArchiveCommandLine.h
2 
3 #ifndef __ARCHIVE_COMMAND_LINE_H
4 #define __ARCHIVE_COMMAND_LINE_H
5 
6 #include "../../../Common/CommandLineParser.h"
7 #include "../../../Common/Wildcard.h"
8 
9 #include "Extract.h"
10 #include "HashCalc.h"
11 #include "Update.h"
12 
13 struct CArcCmdLineException: public UString
14 {
15   CArcCmdLineException(const char *a, const wchar_t *u = NULL);
16 };
17 
18 namespace NCommandType { enum EEnum
19 {
20   kAdd = 0,
21   kUpdate,
22   kDelete,
23   kTest,
24   kExtract,
25   kExtractFull,
26   kList,
27   kBenchmark,
28   kInfo,
29   kHash,
30   kRename
31 };}
32 
33 struct CArcCommand
34 {
35   NCommandType::EEnum CommandType;
36 
37   bool IsFromExtractGroup() const;
38   bool IsFromUpdateGroup() const;
IsTestCommandCArcCommand39   bool IsTestCommand() const { return CommandType == NCommandType::kTest; }
40   NExtract::NPathMode::EEnum GetPathMode() const;
41 };
42 
43 enum
44 {
45   k_OutStream_disabled = 0,
46   k_OutStream_stdout = 1,
47   k_OutStream_stderr = 2
48 };
49 
50 struct CArcCmdLineOptions
51 {
52   bool HelpMode;
53 
54   bool LargePages;
55   bool CaseSensitiveChange;
56   bool CaseSensitive;
57 
58   bool IsInTerminal;
59   bool IsStdOutTerminal;
60   bool IsStdErrTerminal;
61   bool StdInMode;
62   bool StdOutMode;
63   bool EnableHeaders;
64 
65   bool YesToAll;
66   bool ShowDialog;
67   NWildcard::CCensor Censor;
68 
69   CArcCommand Command;
70   UString ArchiveName;
71 
72   #ifndef _NO_CRYPTO
73   bool PasswordEnabled;
74   UString Password;
75   #endif
76 
77   bool TechMode;
78   bool ShowTime;
79 
80   UStringVector HashMethods;
81 
82   bool AppendName;
83   // UStringVector ArchivePathsSorted;
84   // UStringVector ArchivePathsFullSorted;
85   NWildcard::CCensor arcCensor;
86   UString ArcName_for_StdInMode;
87 
88   CObjectVector<CProperty> Properties;
89 
90   CExtractOptionsBase ExtractOptions;
91 
92   CBoolPair NtSecurity;
93   CBoolPair AltStreams;
94   CBoolPair HardLinks;
95   CBoolPair SymLinks;
96 
97   CUpdateOptions UpdateOptions;
98   CHashOptions HashOptions;
99   UString ArcType;
100   UStringVector ExcludedArcTypes;
101 
102   unsigned Number_for_Out;
103   unsigned Number_for_Errors;
104   unsigned Number_for_Percents;
105   unsigned LogLevel;
106 
107   // bool IsOutAllowed() const { return Number_for_Out != k_OutStream_disabled; }
108 
109   // Benchmark
110   UInt32 NumIterations;
111 
CArcCmdLineOptionsCArcCmdLineOptions112   CArcCmdLineOptions():
113       LargePages(false),
114       CaseSensitiveChange(false),
115       CaseSensitive(false),
116 
117       StdInMode(false),
118       StdOutMode(false),
119 
120       Number_for_Out(k_OutStream_stdout),
121       Number_for_Errors(k_OutStream_stderr),
122       Number_for_Percents(k_OutStream_stdout),
123 
124       LogLevel(0)
125   {
126   };
127 };
128 
129 class CArcCmdLineParser
130 {
131   NCommandLineParser::CParser parser;
132 public:
133   CArcCmdLineParser();
134   void Parse1(const UStringVector &commandStrings, CArcCmdLineOptions &options);
135   void Parse2(CArcCmdLineOptions &options);
136 };
137 
138 HRESULT EnumerateDirItemsAndSort(
139     NWildcard::CCensor &censor,
140     NWildcard::ECensorPathMode pathMode,
141     const UString &addPathPrefix,
142     UStringVector &sortedPaths,
143     UStringVector &sortedFullPaths,
144     CDirItemsStat &st,
145     IDirItemsCallback *callback);
146 
147 #endif
148