public string Analyse(AnalysisOptions options) { var sw = new Stopwatch(); sw.Start(); var analysisResult = new AnalysisResult {Path = options.Path}; if (File.Exists(analysisResult.Path)) { analysisResult.Add(AnalyseFile(analysisResult.Path, options)); } else { analysisResult.Merge(AnalyseDirectory(analysisResult.Path, options)); } sw.Stop(); analysisResult.ElapsedMilliseconds = sw.ElapsedMilliseconds; return analysisResult.ToString(); }
private AnalysisResult AnalyseDirectory(string path, AnalysisOptions options) { var analysisResult = new AnalysisResult(); UpdateStatus("Analysing directory:", path, options); analysisResult.Path = path; foreach (var item in Directory.EnumerateFiles(path)) { var analysis = AnalyseFile(item, options); analysisResult.Add(analysis); } if (!options.Recurse) return analysisResult; foreach (var item in Directory.EnumerateDirectories(path)) { if (!options.ShouldScanDirectory(item)) { UpdateStatus("Skipping directory:", item, options); continue; } var directoryAnalysis = AnalyseDirectory(item, options); analysisResult.Merge(directoryAnalysis); } return analysisResult; }
public void Merge(AnalysisResult analyseDirectory) { TotalDirectoryCount++; TotalDirectoryCount += analyseDirectory.TotalDirectoryCount; IgnoredFileCount += analyseDirectory.IgnoredFileCount; TotalFileCount += analyseDirectory.TotalFileCount; BinaryFileCount += analyseDirectory.BinaryFileCount; foreach (var fileResult in analyseDirectory.FileResults.Values) { UpdateStats(fileResult); } }