private void ProcessFile(string outFile, string errFile, bool imageScan, string file) { // Process files try { // If there is a file processor for a give file extension, process the file.. foreach (var fm in from fm in smgr.FileReaders where smgr.SupportFileExtension(fm, Path.GetExtension(file)) select fm) { // Read the text var fc = fm.ReadAllText(file, imageScan); // Scan the text for patterns scanEngine.Scan(fc.Text); // Output start PrintProcessingStart(outFile, file, fc, imageScan); foreach (var match in scanEngine.PatternsFound.OrderBy(idx => idx.Index)) { PrintMatch(outFile, match, imageScan); } } } catch (Exception err) { File.AppendAllText(errFile, $"An error occured while processing: {file} => {err.Message}\n"); } }
private void ProcessDirectories(SearchManager smgr, Scanner.ScanEngine s, string outFile, string errFile, bool imageScan, string[] files) { var starttime = DateTime.Now; // Print header PrintHeader(outFile, imageScan); // Process files var processedfiles = 0; foreach (var file in files) { try { // If there is a file processor for a give file extension, process the file.. foreach (var fm in from fm in smgr.FileReaders where smgr.SupportFileExtension(fm, Path.GetExtension(file)) select fm) { // Only count if we have a file processor ++processedfiles; // Read the text var fc = fm.ReadAllText(file, imageScan); // Scan the text for patterns s.Scan(fc.Text); // Output start PrintProcessingStart(outFile, s, file, fc, imageScan); foreach (var match in s.PatternsFound.OrderBy(idx => idx.Index)) { PrintMatch(outFile, match, imageScan); } } } catch (Exception err) { File.AppendAllText(errFile, $"An error occured while processing: {file} => {err.Message}\n"); } } if (processedfiles > 0) { PrintFooter(outFile, starttime, processedfiles, s.GetPatternNames()); } }