185 } |
187 } |
186 |
188 |
187 } |
189 } |
188 |
190 |
189 //Parameter scanning finished - validate content |
191 //Parameter scanning finished - validate content |
|
192 if (CommandLineUsage) |
|
193 { |
|
194 if (iMetaData.Count == 0 && DecodeWithoutSymbols == false) |
|
195 { |
|
196 System.Console.WriteLine("Error: No symbol files given. Give symbol files with parameter -m"); |
|
197 retval = false; |
|
198 } |
|
199 |
|
200 if (!UseXmlSink) |
|
201 { |
|
202 // Plain text output as default in command line usage. |
|
203 UseXmlSink = true; |
|
204 iSinkParams.PlainTextOutput = true; |
|
205 } |
|
206 |
|
207 // When used in command line mode set current directory as default archive, |
|
208 // error and skipped path (just some valid dir as it is not really used). |
|
209 if (ArchivePath == String.Empty || SkippedPath == String.Empty) |
|
210 { |
|
211 if (ArchivePath != String.Empty || SkippedPath != String.Empty) |
|
212 { |
|
213 System.Console.WriteLine("Please give either both the archive path and the skipped path, or neither of them."); |
|
214 System.Console.WriteLine("Not moving any files."); |
|
215 } |
|
216 NotMovingFiles = true; |
|
217 ArchivePath = Directory.GetCurrentDirectory(); |
|
218 SkippedPath = ArchivePath; |
|
219 ErrorPath = SkippedPath + @"\errors"; |
|
220 } |
|
221 } |
|
222 |
190 if (ArchivePath == string.Empty) |
223 if (ArchivePath == string.Empty) |
191 { |
224 { |
192 System.Console.WriteLine("Error: No archive path given"); |
225 System.Console.WriteLine("Error: No archive path given"); |
193 retval = false; |
226 retval = false; |
194 } |
227 } |
208 System.Console.WriteLine("Error: Skipped path " + SkippedPath + " cannot be found"); |
241 System.Console.WriteLine("Error: Skipped path " + SkippedPath + " cannot be found"); |
209 retval = false; |
242 retval = false; |
210 } |
243 } |
211 else //skipped path exists, create error path if not there |
244 else //skipped path exists, create error path if not there |
212 { |
245 { |
213 if (!Directory.Exists(ErrorPath)) |
246 if (!Directory.Exists(ErrorPath) && !NotMovingFiles) |
214 { |
247 { |
215 Directory.CreateDirectory(ErrorPath); |
248 Directory.CreateDirectory(ErrorPath); |
216 } |
249 } |
217 |
250 |
218 } |
251 } |
243 iArchivePath = iArchivePath + @"\" + year + "_" + weekNum.ToString().PadLeft(2, '0'); |
276 iArchivePath = iArchivePath + @"\" + year + "_" + weekNum.ToString().PadLeft(2, '0'); |
244 iSkippedPath = iSkippedPath + @"\" + year + "_" + weekNum.ToString().PadLeft(2, '0'); |
277 iSkippedPath = iSkippedPath + @"\" + year + "_" + weekNum.ToString().PadLeft(2, '0'); |
245 iErrorPath = iErrorPath + @"\" + year + "_" + weekNum.ToString().PadLeft(2, '0'); |
278 iErrorPath = iErrorPath + @"\" + year + "_" + weekNum.ToString().PadLeft(2, '0'); |
246 |
279 |
247 |
280 |
248 if (TestWithoutMovingFiles) |
281 if (NotMovingFiles) |
249 { |
282 { |
250 System.Console.WriteLine("Test mode parameter -t given: Not moving any files!" ); |
283 System.Console.WriteLine("Not moving any files!" ); |
251 retval = true; |
|
252 } |
284 } |
253 else if (retval) //Archive & skipped directories exsits, clean up paths and add week numbers |
285 else if (retval) //Archive & skipped directories exsits, clean up paths and add week numbers |
254 { |
286 { |
255 |
287 |
256 if (!Directory.Exists(iArchivePath)) |
288 if (!Directory.Exists(iArchivePath)) |
268 } |
300 } |
269 else |
301 else |
270 { |
302 { |
271 PrintCommandHelp(); |
303 PrintCommandHelp(); |
272 } |
304 } |
273 System.Console.WriteLine("Using archive path " + ArchivePath + ", skipped path " + SkippedPath + " and error path " + ErrorPath); |
305 |
274 |
306 if (!NotMovingFiles) |
|
307 { |
|
308 System.Console.WriteLine("Using archive path " + ArchivePath + ", skipped path " + SkippedPath + " and error path " + ErrorPath); |
|
309 } |
275 |
310 |
276 return retval; |
311 return retval; |
277 } |
312 } |
278 |
313 |
279 private void PrintCommandHelp() |
314 private void PrintCommandHelp() |
280 { |
315 { |
|
316 System.Console.WriteLine("Usage example:"); |
|
317 System.Console.WriteLine("CrashAnalyserServerExe.exe -b crashfile.bin -m mapfiles.zip,rom.symbol"); |
|
318 System.Console.WriteLine(); |
281 System.Console.WriteLine("Command line parameters:"); |
319 System.Console.WriteLine("Command line parameters:"); |
282 System.Console.WriteLine("-a C:\\folderarchive\\ Location where to move files to permanent archive."); |
320 System.Console.WriteLine("-b crashfile.bin Crash file to be decoded."); |
283 System.Console.WriteLine("-s C:\\folder\\skipped\\ Location where to put skipped files to wait reprocessing."); |
|
284 System.Console.WriteLine("-c C:\\folder\\output\\ Location where to put output files. Defaults to current working dir."); |
|
285 System.Console.WriteLine("-b crashfile.bin Crash file to be decoded."); |
|
286 System.Console.WriteLine("-m crash.symbol,crash.map Symbol/map/dictionary files."); |
321 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."); |
322 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."); |
323 System.Console.WriteLine("-x Prints output in Xml format"); |
289 System.Console.WriteLine("-x Prints output in Xml format"); |
324 System.Console.WriteLine("-p Prints output in plain text format (default)"); |
290 System.Console.WriteLine("-p Prints output in plain text format"); |
325 System.Console.WriteLine(); |
|
326 System.Console.WriteLine("For server usage:"); |
|
327 System.Console.WriteLine("-a C:\\folderarchive\\ Location where to move files to permanent archive."); |
|
328 System.Console.WriteLine("-s C:\\folder\\skipped\\ Location where to put skipped"); |
|
329 System.Console.WriteLine(" files to wait reprocessing."); |
|
330 System.Console.WriteLine("-c C:\\folder\\output\\ Location where to put output files."); |
|
331 System.Console.WriteLine(" Defaults to current working dir."); |
|
332 System.Console.WriteLine("-t Will not move any files,"); |
|
333 System.Console.WriteLine(" ignores -a and -s."); |
|
334 System.Console.WriteLine(); |
291 } |
335 } |
292 |
336 |
293 #endregion |
337 #endregion |
294 |
338 |
295 #region API |
339 #region API |
335 public bool DecodeWithoutSymbols |
379 public bool DecodeWithoutSymbols |
336 { |
380 { |
337 get { return iDecodeWithoutSymbols; } |
381 get { return iDecodeWithoutSymbols; } |
338 set { iDecodeWithoutSymbols = value; } |
382 set { iDecodeWithoutSymbols = value; } |
339 } |
383 } |
340 public bool TestWithoutMovingFiles |
384 public bool NotMovingFiles |
341 { |
385 { |
342 get { return iTestWithoutMovingFiles; } |
386 get { return iNotMovingFiles; } |
343 set { iTestWithoutMovingFiles = value; } |
387 set { iNotMovingFiles = value; } |
|
388 } |
|
389 public bool SymbolsGiven |
|
390 { |
|
391 get { return iSymbolsGiven; } |
|
392 set { iSymbolsGiven = value; } |
344 } |
393 } |
345 public bool UseXmlSink |
394 public bool UseXmlSink |
346 { |
395 { |
347 get { return iUseXmlSink; } |
396 get { return iUseXmlSink; } |
348 set { iUseXmlSink = value; } |
397 set { iUseXmlSink = value; } |
349 } |
398 } |
350 |
399 public bool CommandLineUsage |
|
400 { |
|
401 get { return iCommandLineUsage; } |
|
402 set { iCommandLineUsage = value; } |
|
403 } |
351 #endregion |
404 #endregion |
352 |
405 |
353 #region Internal constants |
406 #region Internal constants |
354 private const string KDebugMetaDataFileSelgeIni = "selge.ini"; |
407 private const string KDebugMetaDataFileSelgeIni = "selge.ini"; |
355 private const string KDebugMetaDataFileSelgeEventIni = "selge_event.ini"; |
408 private const string KDebugMetaDataFileSelgeEventIni = "selge_event.ini"; |
394 |
447 |
395 private string iCITargetPath = string.Empty; |
448 private string iCITargetPath = string.Empty; |
396 private string iArchivePath = string.Empty; |
449 private string iArchivePath = string.Empty; |
397 private string iSkippedPath = string.Empty; |
450 private string iSkippedPath = string.Empty; |
398 private string iErrorPath = string.Empty; |
451 private string iErrorPath = string.Empty; |
399 private bool iTestWithoutMovingFiles = false; |
452 private bool iNotMovingFiles = false; |
|
453 private bool iSymbolsGiven = false; |
400 private bool iUseXmlSink = false; |
454 private bool iUseXmlSink = false; |
401 private bool iDecodeWithoutSymbols = false; |
455 private bool iDecodeWithoutSymbols = false; |
|
456 private bool iCommandLineUsage = false; |
402 |
457 |
403 |
458 |
404 |
459 |
405 |
460 |
406 |
461 |