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 struct CArcCmdLineOptions
44 {
45   bool HelpMode;
46 
47   #ifdef _WIN32
48   bool LargePages;
49   #endif
50   bool CaseSensitiveChange;
51   bool CaseSensitive;
52 
53   bool IsInTerminal;
54   bool IsStdOutTerminal;
55   bool IsStdErrTerminal;
56   bool StdInMode;
57   bool StdOutMode;
58   bool EnableHeaders;
59 
60   bool YesToAll;
61   bool ShowDialog;
62   NWildcard::CCensor Censor;
63 
64   CArcCommand Command;
65   UString ArchiveName;
66 
67   #ifndef _NO_CRYPTO
68   bool PasswordEnabled;
69   UString Password;
70   #endif
71 
72   bool TechMode;
73 
74   UStringVector HashMethods;
75 
76   bool AppendName;
77   UStringVector ArchivePathsSorted;
78   UStringVector ArchivePathsFullSorted;
79   CObjectVector<CProperty> Properties;
80 
81   CExtractOptionsBase ExtractOptions;
82 
83   CBoolPair NtSecurity;
84   CBoolPair AltStreams;
85   CBoolPair HardLinks;
86   CBoolPair SymLinks;
87 
88   CUpdateOptions UpdateOptions;
89   CHashOptions HashOptions;
90   UString ArcType;
91   UStringVector ExcludedArcTypes;
92   bool EnablePercents;
93 
94   // Benchmark
95   UInt32 NumIterations;
96 
CArcCmdLineOptionsCArcCmdLineOptions97   CArcCmdLineOptions():
98       StdInMode(false),
99       StdOutMode(false),
100       CaseSensitiveChange(false),
101       CaseSensitive(false)
102       {};
103 };
104 
105 class CArcCmdLineParser
106 {
107   NCommandLineParser::CParser parser;
108 public:
109   CArcCmdLineParser();
110   void Parse1(const UStringVector &commandStrings, CArcCmdLineOptions &options);
111   void Parse2(CArcCmdLineOptions &options);
112 };
113 
114 void EnumerateDirItemsAndSort(
115     bool storeAltStreams,
116     NWildcard::CCensor &censor,
117     NWildcard::ECensorPathMode pathMode,
118     const UString &addPathPrefix,
119     UStringVector &sortedPaths,
120     UStringVector &sortedFullPaths);
121 
122 #endif
123