crashanalysercmd/UI/CrashServer/Engine/Inputs/CACmdLineInputParameters.cs
changeset 2 0c91f0baec58
parent 0 818e61de6cd1
child 3 045ade241ef5
equal deleted inserted replaced
1:7a31f7298d8f 2:0c91f0baec58
    66             Version version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
    66             Version version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
    67             string commandLine = System.Environment.CommandLine;
    67             string commandLine = System.Environment.CommandLine;
    68             iSinkParams = new CISinkSerializationParameters( version, commandLine );
    68             iSinkParams = new CISinkSerializationParameters( version, commandLine );
    69             iSinkParams.DetailLevel = CISinkSerializationParameters.TDetailLevel.EFull;
    69             iSinkParams.DetailLevel = CISinkSerializationParameters.TDetailLevel.EFull;
    70             iSinkParams.FileExtensionFailed = ".corrupt_ci";
    70             iSinkParams.FileExtensionFailed = ".corrupt_ci";
    71             iSinkParams.FileExtensionFailed = ".ci";
    71             iSinkParams.FileExtensionSuccess = ".ci";
    72 
    72 
    73             // CHECKME:
    73             // CHECKME:
    74             // The output data is written to the same directory as the input file.
    74             // The output data is written to the same directory as the input file.
    75             iSinkParams.OutputDirectory = sourceDir;
    75             iSinkParams.OutputDirectory = sourceDir;
    76         }
    76         }
   116                     }
   116                     }
   117                     if (paramId == "-t")
   117                     if (paramId == "-t")
   118                     {
   118                     {
   119                         TestWithoutMovingFiles = true;
   119                         TestWithoutMovingFiles = true;
   120                     }
   120                     }
   121 
   121                     if (paramId == "-x")
       
   122                     {
       
   123                         UseXmlSink = true;
       
   124                     }
       
   125 
       
   126                     if (paramId == "-c")
       
   127                     {
       
   128                         CITargetPath = paramContent;
       
   129                         System.Console.WriteLine("CITargetPath -c is " +CITargetPath);
       
   130                     }
       
   131                     
       
   132                     // Plain text output
       
   133                     if (paramId == "-p")
       
   134                     {
       
   135                         UseXmlSink = true; // XML sink is used for plain text output
       
   136                         iSinkParams.PlainTextOutput = true;
       
   137                     }
       
   138                     
       
   139                     // Crash files
       
   140                     if (paramId == "-b")
       
   141                     {
       
   142                         FileInfo fi = new FileInfo(paramContent);
       
   143                         CACmdLineFSEntityList<CACmdLineFileSource> fileList = new CACmdLineFSEntityList<CACmdLineFileSource>();
       
   144 
       
   145                         if (fi.Exists)
       
   146                         {
       
   147                             fileList.Add(fi);
       
   148                         }
       
   149                         else
       
   150                         {
       
   151                             System.Console.WriteLine("Error: Crash file " + fi.FullName + " does not exist");
       
   152                             retval = false;
       
   153                         }
       
   154                         iSources = fileList;
       
   155                     }
       
   156                     
       
   157                     // Symbol/map/dictionary files
       
   158                     if (paramId == "-m")
       
   159                     {
       
   160                         string[] symbolFileTable = paramContent.Split(',');
       
   161                         CACmdLineFSEntityList<CACmdLineFSEntity> fileList = new CACmdLineFSEntityList<CACmdLineFSEntity>();
       
   162                         foreach (string fileName in symbolFileTable)
       
   163                         {
       
   164                             FileInfo fi = new FileInfo(fileName);
       
   165                             if(fi.Exists)
       
   166                             {
       
   167                                 fileList.Add(fi);
       
   168                             }
       
   169                         }
       
   170                         
       
   171                         iMetaData = fileList;
       
   172 
       
   173                         if (fileList.Count == 0)
       
   174                         {
       
   175                             System.Console.WriteLine("Error: Invalid symbol/map/dictionary files: " + paramContent);
       
   176                             retval = false;
       
   177                         }
       
   178                     }
       
   179                     
   122                 }
   180                 }
   123                 else
   181                 else
   124                 {
   182                 {
   125                     System.Console.WriteLine("Error: No parameters found");
   183                     System.Console.WriteLine("Error: No parameters found");
   126                     retval = false;
   184                     retval = false;
   155                 if (!Directory.Exists(ErrorPath))
   213                 if (!Directory.Exists(ErrorPath))
   156                 {
   214                 {
   157                     Directory.CreateDirectory(ErrorPath);
   215                     Directory.CreateDirectory(ErrorPath);
   158                 }
   216                 }
   159                 
   217                 
       
   218             }
       
   219 
       
   220             if (CITargetPath != string.Empty)
       
   221             {
       
   222                 CITargetPath = Path.GetFullPath(CITargetPath);
       
   223                 System.Console.WriteLine("CITargetPath used! Resulting files will be created to " +CITargetPath);
       
   224                 
       
   225                 if (!Directory.Exists(CITargetPath))
       
   226                 {
       
   227                     Directory.CreateDirectory(CITargetPath);
       
   228                 }
       
   229                 iSinkParams.OutputDirectory = new DirectoryInfo(CITargetPath);
   160             }
   230             }
   161 
   231 
   162             //make sure paths are absolute
   232             //make sure paths are absolute
   163             iArchivePath = Path.GetFullPath(iArchivePath);
   233             iArchivePath = Path.GetFullPath(iArchivePath);
   164             iSkippedPath = Path.GetFullPath(iSkippedPath);
   234             iSkippedPath = Path.GetFullPath(iSkippedPath);
   207         }
   277         }
   208 
   278 
   209         private void PrintCommandHelp()
   279         private void PrintCommandHelp()
   210         {
   280         {
   211             System.Console.WriteLine("Command line parameters:");
   281             System.Console.WriteLine("Command line parameters:");
   212             System.Console.WriteLine("-a C:\\folderarchive\\   --Location where to move files to permanent archive");
   282             System.Console.WriteLine("-a C:\\folderarchive\\   Location where to move files to permanent archive.");
   213             System.Console.WriteLine("-s C:\\folder\\skipped\\  --Location whére to put skipped files to wait reprocessing");
   283             System.Console.WriteLine("-s C:\\folder\\skipped\\  Location where to put skipped files to wait reprocessing.");
   214             System.Console.WriteLine("-f --Force decoding even if files are without symbols");
   284             System.Console.WriteLine("-c C:\\folder\\output\\ Location where to put output files. Defaults to current working dir.");
   215             System.Console.WriteLine("-t --Test mode, will not move any files, ignores -a and -s");
   285             System.Console.WriteLine("-b crashfile.bin   Crash file to be decoded.");
   216 
   286             System.Console.WriteLine("-m crash.symbol,crash.map   Symbol/map/dictionary files.");
       
   287             System.Console.WriteLine("-f Force decoding even if files are without symbols.");
       
   288             System.Console.WriteLine("-t Test mode, will not move any files, ignores -a and -s.");
       
   289             System.Console.WriteLine("-x Prints output in Xml format");
       
   290             System.Console.WriteLine("-p Prints output in plain text format");
   217         }
   291         }
   218 
   292 
   219         #endregion
   293         #endregion
   220 
   294 
   221         #region API
   295         #region API
   228         }
   302         }
   229 
   303 
   230         public CACmdLineFSEntityList<CACmdLineFileSource> SourceFiles
   304         public CACmdLineFSEntityList<CACmdLineFileSource> SourceFiles
   231         {
   305         {
   232             get { return iSources; }
   306             get { return iSources; }
       
   307             set { iSources = value; }
   233         }
   308         }
   234 
   309 
   235         public CACmdLineFSEntityList<CACmdLineFSEntity> MetaDataFiles
   310         public CACmdLineFSEntityList<CACmdLineFSEntity> MetaDataFiles
   236         {
   311         {
   237             get { return iMetaData; }
   312             get { return iMetaData; }
   250         public string ErrorPath
   325         public string ErrorPath
   251         {
   326         {
   252             get { return iErrorPath; }
   327             get { return iErrorPath; }
   253             set { iErrorPath = value; }
   328             set { iErrorPath = value; }
   254         }
   329         }
       
   330         public string CITargetPath
       
   331         {
       
   332             get { return iCITargetPath; }
       
   333             set { iCITargetPath = value; }
       
   334         }  
   255         public bool DecodeWithoutSymbols
   335         public bool DecodeWithoutSymbols
   256         {
   336         {
   257             get { return iDecodeWithoutSymbols; }
   337             get { return iDecodeWithoutSymbols; }
   258             set { iDecodeWithoutSymbols = value; }
   338             set { iDecodeWithoutSymbols = value; }
   259         }
   339         }
   260         public bool TestWithoutMovingFiles
   340         public bool TestWithoutMovingFiles
   261         {
   341         {
   262             get { return iTestWithoutMovingFiles; }
   342             get { return iTestWithoutMovingFiles; }
   263             set { iTestWithoutMovingFiles = value; }
   343             set { iTestWithoutMovingFiles = value; }
       
   344         }
       
   345         public bool UseXmlSink
       
   346         {
       
   347             get { return iUseXmlSink; }
       
   348             set { iUseXmlSink = value; }
   264         }
   349         }
   265 
   350 
   266         #endregion
   351         #endregion
   267 
   352 
   268         #region Internal constants
   353         #region Internal constants
   305         private readonly string iAppPath;
   390         private readonly string iAppPath;
   306         private readonly CISinkSerializationParameters iSinkParams;
   391         private readonly CISinkSerializationParameters iSinkParams;
   307         private CACmdLineFSEntityList<CACmdLineFSEntity> iMetaData = new CACmdLineFSEntityList<CACmdLineFSEntity>();
   392         private CACmdLineFSEntityList<CACmdLineFSEntity> iMetaData = new CACmdLineFSEntityList<CACmdLineFSEntity>();
   308         private CACmdLineFSEntityList<CACmdLineFileSource> iSources = new CACmdLineFSEntityList<CACmdLineFileSource>();
   393         private CACmdLineFSEntityList<CACmdLineFileSource> iSources = new CACmdLineFSEntityList<CACmdLineFileSource>();
   309 
   394 
       
   395         private string iCITargetPath = string.Empty;  
   310         private string iArchivePath = string.Empty;       
   396         private string iArchivePath = string.Empty;       
   311         private string iSkippedPath = string.Empty;      
   397         private string iSkippedPath = string.Empty;      
   312         private string iErrorPath = string.Empty;    
   398         private string iErrorPath = string.Empty;    
   313         private bool iTestWithoutMovingFiles = false;
   399         private bool iTestWithoutMovingFiles = false;
       
   400         private bool iUseXmlSink = false;
   314         private bool iDecodeWithoutSymbols = false;
   401         private bool iDecodeWithoutSymbols = false;
   315 
   402 
   316 
   403 
   317 
   404 
   318   
   405