From e46011beff20ff880ff162ef812b2366504a627b Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Thu, 5 Jan 2023 10:46:13 -0800 Subject: [PATCH] Add path scanning flag in Scanner --- BurnOutSharp/Scanner.cs | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/BurnOutSharp/Scanner.cs b/BurnOutSharp/Scanner.cs index 5489d9a6..f38f5c2b 100644 --- a/BurnOutSharp/Scanner.cs +++ b/BurnOutSharp/Scanner.cs @@ -25,6 +25,11 @@ namespace BurnOutSharp /// public bool ScanPackers { get; private set; } + /// + /// Determines if path matches are used or not + /// + public bool ScanPaths { get; private set; } + /// /// Determines if debug information is output or not /// @@ -42,12 +47,14 @@ namespace BurnOutSharp /// /// Enable scanning archive contents /// Enable including packers in output + /// Enable including path detections in output /// Enable including debug information /// Optional progress callback - public Scanner(bool scanArchives, bool scanPackers, bool includeDebug, IProgress fileProgress = null) + public Scanner(bool scanArchives, bool scanPackers, bool scanPaths, bool includeDebug, IProgress fileProgress = null) { ScanArchives = scanArchives; ScanPackers = scanPackers; + ScanPaths = scanPaths; IncludeDebug = includeDebug; this.fileProgress = fileProgress; @@ -98,8 +105,11 @@ namespace BurnOutSharp var files = Directory.EnumerateFiles(path, "*", SearchOption.AllDirectories).ToList(); // Scan for path-detectable protections - var directoryPathProtections = GetDirectoryPathProtections(path, files); - AppendToDictionary(protections, directoryPathProtections); + if (ScanPaths) + { + var directoryPathProtections = GetDirectoryPathProtections(path, files); + AppendToDictionary(protections, directoryPathProtections); + } // Scan each file in directory separately for (int i = 0; i < files.Count; i++) @@ -116,8 +126,11 @@ namespace BurnOutSharp this.fileProgress?.Report(new ProtectionProgress(reportableFileName, i / (float)files.Count, "Checking file" + (file != reportableFileName ? " from archive" : string.Empty))); // Scan for path-detectable protections - var filePathProtections = GetFilePathProtections(file); - AppendToDictionary(protections, filePathProtections); + if (ScanPaths) + { + var filePathProtections = GetFilePathProtections(file); + AppendToDictionary(protections, filePathProtections); + } // Scan for content-detectable protections var fileProtections = GetInternalProtections(file); @@ -151,8 +164,11 @@ namespace BurnOutSharp this.fileProgress?.Report(new ProtectionProgress(reportableFileName, 0, "Checking file" + (path != reportableFileName ? " from archive" : string.Empty))); // Scan for path-detectable protections - var filePathProtections = GetFilePathProtections(path); - AppendToDictionary(protections, filePathProtections); + if (ScanPaths) + { + var filePathProtections = GetFilePathProtections(path); + AppendToDictionary(protections, filePathProtections); + } // Scan for content-detectable protections var fileProtections = GetInternalProtections(path); @@ -456,7 +472,7 @@ namespace BurnOutSharp PrependToKeys(subProtections, fileName); AppendToDictionary(protections, subProtections); } - + // PAK if (fileName != null && scannable is PAK) {