Home | History | Annotate | Download | only in Common
      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 "Update.h"
     11 
     12 struct CArchiveCommandLineException: public AString
     13 {
     14   CArchiveCommandLineException(const char *errorMessage): AString(errorMessage) {}
     15 };
     16 
     17 namespace NCommandType { enum EEnum
     18 {
     19   kAdd = 0,
     20   kUpdate,
     21   kDelete,
     22   kTest,
     23   kExtract,
     24   kFullExtract,
     25   kList,
     26   kBenchmark,
     27   kInfo
     28 };}
     29 
     30 namespace NRecursedType { enum EEnum
     31 {
     32   kRecursed,
     33   kWildCardOnlyRecursed,
     34   kNonRecursed
     35 };}
     36 
     37 struct CArchiveCommand
     38 {
     39   NCommandType::EEnum CommandType;
     40   bool IsFromExtractGroup() const;
     41   bool IsFromUpdateGroup() const;
     42   bool IsTestMode() const { return CommandType == NCommandType::kTest; }
     43   NExtract::NPathMode::EEnum GetPathMode() const;
     44 };
     45 
     46 struct CArchiveCommandLineOptions
     47 {
     48   bool HelpMode;
     49 
     50   #ifdef _WIN32
     51   bool LargePages;
     52   #endif
     53 
     54   bool IsInTerminal;
     55   bool IsStdOutTerminal;
     56   bool IsStdErrTerminal;
     57   bool StdInMode;
     58   bool StdOutMode;
     59   bool EnableHeaders;
     60 
     61   bool YesToAll;
     62   bool ShowDialog;
     63   // NWildcard::CCensor ArchiveWildcardCensor;
     64   NWildcard::CCensor WildcardCensor;
     65 
     66   CArchiveCommand Command;
     67   UString ArchiveName;
     68 
     69   #ifndef _NO_CRYPTO
     70   bool PasswordEnabled;
     71   UString Password;
     72   #endif
     73 
     74   bool TechMode;
     75   // Extract
     76   bool CalcCrc;
     77   bool AppendName;
     78   UString OutputDir;
     79   NExtract::NOverwriteMode::EEnum OverwriteMode;
     80   UStringVector ArchivePathsSorted;
     81   UStringVector ArchivePathsFullSorted;
     82   CObjectVector<CProperty> ExtractProperties;
     83 
     84   CUpdateOptions UpdateOptions;
     85   UString ArcType;
     86   bool EnablePercents;
     87 
     88   // Benchmark
     89   UInt32 NumIterations;
     90   UInt32 NumThreads;
     91   UInt32 DictionarySize;
     92   UString Method;
     93 
     94 
     95   CArchiveCommandLineOptions(): StdInMode(false), StdOutMode(false) {};
     96 };
     97 
     98 class CArchiveCommandLineParser
     99 {
    100   NCommandLineParser::CParser parser;
    101 public:
    102   CArchiveCommandLineParser();
    103   void Parse1(const UStringVector &commandStrings, CArchiveCommandLineOptions &options);
    104   void Parse2(CArchiveCommandLineOptions &options);
    105 };
    106 
    107 void EnumerateDirItemsAndSort(NWildcard::CCensor &wildcardCensor,
    108     UStringVector &sortedPaths,
    109     UStringVector &sortedFullPaths);
    110 
    111 #endif
    112