diff --git a/BurnOutSharp/FileType/BFPK.cs b/BurnOutSharp/FileType/BFPK.cs index 494a4b23..4d28a71e 100644 --- a/BurnOutSharp/FileType/BFPK.cs +++ b/BurnOutSharp/FileType/BFPK.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.IO; -using System.Linq; using System.Text; using SharpCompress.Compressors; using SharpCompress.Compressors.Deflate; @@ -18,10 +17,8 @@ namespace BurnOutSharp.FileType return false; } - public static List Scan(Scanner parentScanner, Stream stream, bool includePosition = false) + public static Dictionary> Scan(Scanner parentScanner, Stream stream) { - List protections = new List(); - // If the BFPK file itself fails try { @@ -29,7 +26,7 @@ namespace BurnOutSharp.FileType Directory.CreateDirectory(tempPath); // Create a new scanner for the new temp path - Scanner subScanner = new Scanner(tempPath, parentScanner.FileProgress) + Scanner subScanner = new Scanner(parentScanner.FileProgress) { IncludePosition = parentScanner.IncludePosition, ScanAllFiles = parentScanner.ScanAllFiles, @@ -104,8 +101,7 @@ namespace BurnOutSharp.FileType } // Collect and format all found protections - var fileProtections = ProtectionFind.Scan(tempPath, includePosition); - protections = fileProtections.Select(kvp => kvp.Key.Substring(tempPath.Length) + ": " + kvp.Value.TrimEnd()).ToList(); + var protections = subScanner.GetProtections(tempPath); // If temp directory cleanup fails try @@ -113,10 +109,12 @@ namespace BurnOutSharp.FileType Directory.Delete(tempPath, true); } catch { } + + return protections; } catch { } - return protections; + return null; } } } diff --git a/BurnOutSharp/FileType/BZip2.cs b/BurnOutSharp/FileType/BZip2.cs index d505744e..111b1877 100644 --- a/BurnOutSharp/FileType/BZip2.cs +++ b/BurnOutSharp/FileType/BZip2.cs @@ -17,10 +17,8 @@ namespace BurnOutSharp.FileType return false; } - public static List Scan(Scanner parentScanner, Stream stream, bool includePosition = false) + public static Dictionary> Scan(Scanner parentScanner, Stream stream) { - List protections = new List(); - // If the 7-zip file itself fails try { @@ -28,7 +26,7 @@ namespace BurnOutSharp.FileType Directory.CreateDirectory(tempPath); // Create a new scanner for the new temp path - Scanner subScanner = new Scanner(tempPath, parentScanner.FileProgress) + Scanner subScanner = new Scanner(parentScanner.FileProgress) { IncludePosition = parentScanner.IncludePosition, ScanAllFiles = parentScanner.ScanAllFiles, @@ -45,34 +43,25 @@ namespace BurnOutSharp.FileType { bz2File.CopyTo(fs); } - - // Collect and format all found protections - var fileProtections = ProtectionFind.Scan(tempFile, includePosition); - string protection = string.Join("\r\n", fileProtections.Select(kvp => kvp.Key.Substring(tempPath.Length) + ": " + kvp.Value.TrimEnd())); - - // If tempfile cleanup fails - try - { - File.Delete(tempFile); - } - catch { } - - if (!string.IsNullOrEmpty(protection)) - protections.Add($"\r\n{protection}"); - } - catch { } - - // If temp directory cleanup fails - try - { - Directory.Delete(tempPath, true); } catch { } } + + // Collect and format all found protections + var protections = subScanner.GetProtections(tempPath); + + // If temp directory cleanup fails + try + { + Directory.Delete(tempPath, true); + } + catch { } + + return protections; } catch { } - return protections; + return null; } } } diff --git a/BurnOutSharp/FileType/GZIP.cs b/BurnOutSharp/FileType/GZIP.cs index 18d1ee6e..f81465c4 100644 --- a/BurnOutSharp/FileType/GZIP.cs +++ b/BurnOutSharp/FileType/GZIP.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.IO; -using System.Linq; using SharpCompress.Archives; using SharpCompress.Archives.GZip; @@ -17,10 +16,8 @@ namespace BurnOutSharp.FileType return false; } - public static List Scan(Scanner parentScanner, Stream stream, bool includePosition = false) + public static Dictionary> Scan(Scanner parentScanner, Stream stream) { - List protections = new List(); - // If the gzip file itself fails try { @@ -28,7 +25,7 @@ namespace BurnOutSharp.FileType Directory.CreateDirectory(tempPath); // Create a new scanner for the new temp path - Scanner subScanner = new Scanner(tempPath, parentScanner.FileProgress) + Scanner subScanner = new Scanner(parentScanner.FileProgress) { IncludePosition = parentScanner.IncludePosition, ScanAllFiles = parentScanner.ScanAllFiles, @@ -48,35 +45,26 @@ namespace BurnOutSharp.FileType string tempFile = Path.Combine(tempPath, entry.Key); entry.WriteToFile(tempFile); - - // Collect and format all found protections - var fileProtections = ProtectionFind.Scan(tempFile, includePosition); - string protection = string.Join("\r\n", fileProtections.Select(kvp => kvp.Key.Substring(tempPath.Length) + ": " + kvp.Value.TrimEnd())); - - // If tempfile cleanup fails - try - { - File.Delete(tempFile); - } - catch { } - - if (!string.IsNullOrEmpty(protection)) - protections.Add($"\r\n{entry.Key} - {protection}"); } catch { } } - - // If temp directory cleanup fails - try - { - Directory.Delete(tempPath, true); - } - catch { } } + + // Collect and format all found protections + var protections = subScanner.GetProtections(tempPath); + + // If temp directory cleanup fails + try + { + Directory.Delete(tempPath, true); + } + catch { } + + return protections; } catch { } - return protections; + return null; } } } diff --git a/BurnOutSharp/FileType/InstallShieldCAB.cs b/BurnOutSharp/FileType/InstallShieldCAB.cs index f679b0af..2aefbac7 100644 --- a/BurnOutSharp/FileType/InstallShieldCAB.cs +++ b/BurnOutSharp/FileType/InstallShieldCAB.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.IO; -using System.Linq; using System.Text.RegularExpressions; using UnshieldSharp; @@ -18,10 +17,8 @@ namespace BurnOutSharp.FileType } // TODO: Add stream opening support - public static List Scan(Scanner parentScanner, string file, bool includePosition = false) + public static Dictionary> Scan(Scanner parentScanner, string file) { - List protections = new List(); - // Get the name of the first cabinet file or header string directory = Path.GetDirectoryName(file); string noExtension = Path.GetFileNameWithoutExtension(file); @@ -43,7 +40,7 @@ namespace BurnOutSharp.FileType Directory.CreateDirectory(tempPath); // Create a new scanner for the new temp path - Scanner subScanner = new Scanner(tempPath, parentScanner.FileProgress) + Scanner subScanner = new Scanner(parentScanner.FileProgress) { IncludePosition = parentScanner.IncludePosition, ScanAllFiles = parentScanner.ScanAllFiles, @@ -63,8 +60,7 @@ namespace BurnOutSharp.FileType } // Collect and format all found protections - var fileProtections = ProtectionFind.Scan(tempPath, includePosition); - protections = fileProtections.Select(kvp => kvp.Key.Substring(tempPath.Length) + ": " + kvp.Value.TrimEnd()).ToList(); + var protections = subScanner.GetProtections(tempPath); // If temp directory cleanup fails try @@ -72,11 +68,13 @@ namespace BurnOutSharp.FileType Directory.Delete(tempPath, true); } catch { } + + return protections; } catch { } } - return protections; + return null; } } } diff --git a/BurnOutSharp/FileType/MPQ.cs b/BurnOutSharp/FileType/MPQ.cs index 0f1606fa..cd98a1a6 100644 --- a/BurnOutSharp/FileType/MPQ.cs +++ b/BurnOutSharp/FileType/MPQ.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.IO; -using System.Linq; using StormLibSharp; namespace BurnOutSharp.FileType @@ -17,10 +16,8 @@ namespace BurnOutSharp.FileType } // TODO: Add stream opening support - public static List Scan(Scanner parentScanner, string file, bool includePosition = false) + public static Dictionary> Scan(Scanner parentScanner, string file) { - List protections = new List(); - // If the mpq file itself fails try { @@ -28,7 +25,7 @@ namespace BurnOutSharp.FileType Directory.CreateDirectory(tempPath); // Create a new scanner for the new temp path - Scanner subScanner = new Scanner(tempPath, parentScanner.FileProgress) + Scanner subScanner = new Scanner(parentScanner.FileProgress) { IncludePosition = parentScanner.IncludePosition, ScanAllFiles = parentScanner.ScanAllFiles, @@ -59,22 +56,23 @@ namespace BurnOutSharp.FileType } catch { } } - - // Collect and format all found protections - var fileProtections = ProtectionFind.Scan(tempPath, includePosition); - protections = fileProtections.Select(kvp => kvp.Key.Substring(tempPath.Length) + ": " + kvp.Value.TrimEnd()).ToList(); - - // If temp directory cleanup fails - try - { - Directory.Delete(tempPath, true); - } - catch { } } + + // Collect and format all found protections + var protections = subScanner.GetProtections(tempPath); + + // If temp directory cleanup fails + try + { + Directory.Delete(tempPath, true); + } + catch { } + + return protections; } catch { } - return protections; + return null; } } } diff --git a/BurnOutSharp/FileType/MSI.cs b/BurnOutSharp/FileType/MSI.cs index 20f8f1f9..fd12be8c 100644 --- a/BurnOutSharp/FileType/MSI.cs +++ b/BurnOutSharp/FileType/MSI.cs @@ -1,12 +1,7 @@ using System; using System.Collections.Generic; using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using LibMSPackN; using Microsoft.Deployment.WindowsInstaller; -using Microsoft.Deployment.WindowsInstaller.Package; namespace BurnOutSharp.FileType { @@ -21,10 +16,8 @@ namespace BurnOutSharp.FileType } // TODO: Add stream opening support - public static List Scan(Scanner parentScanner, string file, bool includePosition = false) + public static Dictionary> Scan(Scanner parentScanner, string file) { - List protections = new List(); - // If the MSI file itself fails try { @@ -32,7 +25,7 @@ namespace BurnOutSharp.FileType Directory.CreateDirectory(tempPath); // Create a new scanner for the new temp path - Scanner subScanner = new Scanner(tempPath, parentScanner.FileProgress) + Scanner subScanner = new Scanner(parentScanner.FileProgress) { IncludePosition = parentScanner.IncludePosition, ScanAllFiles = parentScanner.ScanAllFiles, @@ -45,8 +38,7 @@ namespace BurnOutSharp.FileType } // Collect and format all found protections - var fileProtections = ProtectionFind.Scan(tempPath, includePosition); - protections = fileProtections.Select(kvp => kvp.Key.Substring(tempPath.Length) + ": " + kvp.Value.TrimEnd()).ToList(); + var protections = subScanner.GetProtections(tempPath); // If temp directory cleanup fails try @@ -54,10 +46,12 @@ namespace BurnOutSharp.FileType Directory.Delete(tempPath, true); } catch { } + + return protections; } catch { } - return protections; + return null; } } } diff --git a/BurnOutSharp/FileType/MicrosoftCAB.cs b/BurnOutSharp/FileType/MicrosoftCAB.cs index df025fb8..b16ea7f2 100644 --- a/BurnOutSharp/FileType/MicrosoftCAB.cs +++ b/BurnOutSharp/FileType/MicrosoftCAB.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.IO; -using System.Linq; using LibMSPackN; namespace BurnOutSharp.FileType @@ -17,10 +16,8 @@ namespace BurnOutSharp.FileType } // TODO: Add stream opening support - public static List Scan(Scanner parentScanner, string file, bool includePosition = false) + public static Dictionary> Scan(Scanner parentScanner, string file) { - List protections = new List(); - // If the cab file itself fails try { @@ -28,7 +25,7 @@ namespace BurnOutSharp.FileType Directory.CreateDirectory(tempPath); // Create a new scanner for the new temp path - Scanner subScanner = new Scanner(tempPath, parentScanner.FileProgress) + Scanner subScanner = new Scanner(parentScanner.FileProgress) { IncludePosition = parentScanner.IncludePosition, ScanAllFiles = parentScanner.ScanAllFiles, @@ -50,8 +47,7 @@ namespace BurnOutSharp.FileType } // Collect and format all found protections - var fileProtections = ProtectionFind.Scan(tempPath, includePosition); - protections = fileProtections.Select(kvp => kvp.Key.Substring(tempPath.Length) + ": " + kvp.Value.TrimEnd()).ToList(); + var protections = subScanner.GetProtections(tempPath); // If temp directory cleanup fails try @@ -59,10 +55,12 @@ namespace BurnOutSharp.FileType Directory.Delete(tempPath, true); } catch { } + + return protections; } catch { } - return protections; + return null; } } } diff --git a/BurnOutSharp/FileType/PKZIP.cs b/BurnOutSharp/FileType/PKZIP.cs index 2d4d7fef..1ce74cb6 100644 --- a/BurnOutSharp/FileType/PKZIP.cs +++ b/BurnOutSharp/FileType/PKZIP.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.IO; -using System.Linq; using SharpCompress.Archives; using SharpCompress.Archives.Zip; @@ -26,10 +25,8 @@ namespace BurnOutSharp.FileType return false; } - public static List Scan(Scanner parentScanner, Stream stream, bool includePosition = false) + public static Dictionary> Scan(Scanner parentScanner, Stream stream) { - List protections = new List(); - // If the zip file itself fails try { @@ -37,7 +34,7 @@ namespace BurnOutSharp.FileType Directory.CreateDirectory(tempPath); // Create a new scanner for the new temp path - Scanner subScanner = new Scanner(tempPath, parentScanner.FileProgress) + Scanner subScanner = new Scanner(parentScanner.FileProgress) { IncludePosition = parentScanner.IncludePosition, ScanAllFiles = parentScanner.ScanAllFiles, @@ -60,22 +57,23 @@ namespace BurnOutSharp.FileType } catch { } } - - // Collect and format all found protections - var fileProtections = ProtectionFind.Scan(tempPath, includePosition); - protections = fileProtections.Select(kvp => kvp.Key.Substring(tempPath.Length) + ": " + kvp.Value.TrimEnd()).ToList(); - - // If temp directory cleanup fails - try - { - Directory.Delete(tempPath, true); - } - catch { } } + + // Collect and format all found protections + var protections = subScanner.GetProtections(tempPath); + + // If temp directory cleanup fails + try + { + Directory.Delete(tempPath, true); + } + catch { } + + return protections; } catch { } - return protections; + return null; } } } diff --git a/BurnOutSharp/FileType/RAR.cs b/BurnOutSharp/FileType/RAR.cs index 8a963dfc..0cdc573a 100644 --- a/BurnOutSharp/FileType/RAR.cs +++ b/BurnOutSharp/FileType/RAR.cs @@ -22,10 +22,8 @@ namespace BurnOutSharp.FileType return false; } - public static List Scan(Scanner parentScanner, Stream stream, bool includePosition = false) + public static Dictionary> Scan(Scanner parentScanner, Stream stream) { - List protections = new List(); - // If the rar file itself fails try { @@ -33,7 +31,7 @@ namespace BurnOutSharp.FileType Directory.CreateDirectory(tempPath); // Create a new scanner for the new temp path - Scanner subScanner = new Scanner(tempPath, parentScanner.FileProgress) + Scanner subScanner = new Scanner(parentScanner.FileProgress) { IncludePosition = parentScanner.IncludePosition, ScanAllFiles = parentScanner.ScanAllFiles, @@ -56,22 +54,23 @@ namespace BurnOutSharp.FileType } catch { } } - - // Collect and format all found protections - var fileProtections = ProtectionFind.Scan(tempPath, includePosition); - protections = fileProtections.Select(kvp => kvp.Key.Substring(tempPath.Length) + ": " + kvp.Value.TrimEnd()).ToList(); - - // If temp directory cleanup fails - try - { - Directory.Delete(tempPath, true); - } - catch { } } + + // Collect and format all found protections + var protections = subScanner.GetProtections(tempPath); + + // If temp directory cleanup fails + try + { + Directory.Delete(tempPath, true); + } + catch { } + + return protections; } catch { } - return protections; + return null; } } } diff --git a/BurnOutSharp/FileType/SevenZip.cs b/BurnOutSharp/FileType/SevenZip.cs index f4db9bec..df0e4396 100644 --- a/BurnOutSharp/FileType/SevenZip.cs +++ b/BurnOutSharp/FileType/SevenZip.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.IO; -using System.Linq; using SharpCompress.Archives; using SharpCompress.Archives.SevenZip; @@ -17,10 +16,8 @@ namespace BurnOutSharp.FileType return false; } - public static List Scan(Scanner parentScanner, Stream stream, bool includePosition = false) + public static Dictionary> Scan(Scanner parentScanner, Stream stream) { - List protections = new List(); - // If the 7-zip file itself fails try { @@ -28,7 +25,7 @@ namespace BurnOutSharp.FileType Directory.CreateDirectory(tempPath); // Create a new scanner for the new temp path - Scanner subScanner = new Scanner(tempPath, parentScanner.FileProgress) + Scanner subScanner = new Scanner(parentScanner.FileProgress) { IncludePosition = parentScanner.IncludePosition, ScanAllFiles = parentScanner.ScanAllFiles, @@ -53,8 +50,7 @@ namespace BurnOutSharp.FileType } // Collect and format all found protections - var fileProtections = ProtectionFind.Scan(tempPath, includePosition); - protections = fileProtections.Select(kvp => kvp.Key.Substring(tempPath.Length) + ": " + kvp.Value.TrimEnd()).ToList(); + var protections = subScanner.GetProtections(tempPath); // If temp directory cleanup fails try @@ -62,11 +58,13 @@ namespace BurnOutSharp.FileType Directory.Delete(tempPath, true); } catch { } + + return protections; } } catch { } - return protections; + return null; } } } diff --git a/BurnOutSharp/FileType/TapeArchive.cs b/BurnOutSharp/FileType/TapeArchive.cs index ef35a878..97e678a5 100644 --- a/BurnOutSharp/FileType/TapeArchive.cs +++ b/BurnOutSharp/FileType/TapeArchive.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.IO; -using System.Linq; using SharpCompress.Archives; using SharpCompress.Archives.Tar; @@ -20,10 +19,8 @@ namespace BurnOutSharp.FileType return false; } - public static List Scan(Scanner parentScanner, Stream stream, bool includePosition = false) + public static Dictionary> Scan(Scanner parentScanner, Stream stream) { - List protections = new List(); - // If the tar file itself fails try { @@ -31,7 +28,7 @@ namespace BurnOutSharp.FileType Directory.CreateDirectory(tempPath); // Create a new scanner for the new temp path - Scanner subScanner = new Scanner(tempPath, parentScanner.FileProgress) + Scanner subScanner = new Scanner(parentScanner.FileProgress) { IncludePosition = parentScanner.IncludePosition, ScanAllFiles = parentScanner.ScanAllFiles, @@ -54,22 +51,23 @@ namespace BurnOutSharp.FileType } catch { } } - - // Collect and format all found protections - var fileProtections = ProtectionFind.Scan(tempPath, includePosition); - protections = fileProtections.Select(kvp => kvp.Key.Substring(tempPath.Length) + ": " + kvp.Value.TrimEnd()).ToList(); - - // If temp directory cleanup fails - try - { - Directory.Delete(tempPath, true); - } - catch { } } + + // Collect and format all found protections + var protections = subScanner.GetProtections(tempPath); + + // If temp directory cleanup fails + try + { + Directory.Delete(tempPath, true); + } + catch { } + + return protections; } catch { } - return protections; + return null; } } } diff --git a/BurnOutSharp/FileType/Valve.cs b/BurnOutSharp/FileType/Valve.cs index 1ed8ee16..d22c84bd 100644 --- a/BurnOutSharp/FileType/Valve.cs +++ b/BurnOutSharp/FileType/Valve.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.IO; -using System.Linq; using HLExtract.Net; namespace BurnOutSharp.FileType @@ -34,15 +33,13 @@ namespace BurnOutSharp.FileType } // TODO: Add stream opening support - public static List Scan(Scanner parentScanner, string file, bool includePosition = false) + public static Dictionary> Scan(Scanner parentScanner, string file) { - List protections = new List(); - string tempPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()); Directory.CreateDirectory(tempPath); // Create a new scanner for the new temp path - Scanner subScanner = new Scanner(tempPath, parentScanner.FileProgress) + Scanner subScanner = new Scanner(parentScanner.FileProgress) { IncludePosition = parentScanner.IncludePosition, ScanAllFiles = parentScanner.ScanAllFiles, @@ -61,8 +58,7 @@ namespace BurnOutSharp.FileType HLExtractProgram.Process(args); // Collect and format all found protections - var fileProtections = ProtectionFind.Scan(tempPath, includePosition); - protections = fileProtections.Select(kvp => kvp.Key.Substring(tempPath.Length) + ": " + kvp.Value.TrimEnd()).ToList(); + var protections = subScanner.GetProtections(tempPath); // If temp directory cleanup fails try diff --git a/BurnOutSharp/FileType/XZ.cs b/BurnOutSharp/FileType/XZ.cs index 2dceb4ef..d0afd46e 100644 --- a/BurnOutSharp/FileType/XZ.cs +++ b/BurnOutSharp/FileType/XZ.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.IO; -using System.Linq; using SharpCompress.Compressors.Xz; namespace BurnOutSharp.FileType @@ -16,18 +15,16 @@ namespace BurnOutSharp.FileType return false; } - public static List Scan(Scanner parentScanner, Stream stream, bool includePosition = false) + public static Dictionary> Scan(Scanner parentScanner, Stream stream) { - List protections = new List(); - - // If the 7-zip file itself fails + // If the xz file itself fails try { string tempPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()); Directory.CreateDirectory(tempPath); // Create a new scanner for the new temp path - Scanner subScanner = new Scanner(tempPath, parentScanner.FileProgress) + Scanner subScanner = new Scanner(parentScanner.FileProgress) { IncludePosition = parentScanner.IncludePosition, ScanAllFiles = parentScanner.ScanAllFiles, @@ -44,34 +41,25 @@ namespace BurnOutSharp.FileType { xzFile.CopyTo(fs); } - - // Collect and format all found protections - var fileProtections = ProtectionFind.Scan(tempFile, includePosition); - string protection = string.Join("\r\n", fileProtections.Select(kvp => kvp.Key.Substring(tempPath.Length) + ": " + kvp.Value.TrimEnd())); - - // If tempfile cleanup fails - try - { - File.Delete(tempFile); - } - catch { } - - if (!string.IsNullOrEmpty(protection)) - protections.Add($"\r\n{protection}"); - } - catch { } - - // If temp directory cleanup fails - try - { - Directory.Delete(tempPath, true); } catch { } } + + // Collect and format all found protections + var protections = subScanner.GetProtections(tempPath); + + // If temp directory cleanup fails + try + { + Directory.Delete(tempPath, true); + } + catch { } + + return protections; } catch { } - return protections; + return null; } } } diff --git a/BurnOutSharp/ProtectionType/WiseInstaller.cs b/BurnOutSharp/ProtectionType/WiseInstaller.cs index a9757bc8..59b8b173 100644 --- a/BurnOutSharp/ProtectionType/WiseInstaller.cs +++ b/BurnOutSharp/ProtectionType/WiseInstaller.cs @@ -40,8 +40,7 @@ namespace BurnOutSharp.ProtectionType unpacker.ExtractTo(file, tempPath); // Collect and format all found protections - var fileProtections = ProtectionFind.Scan(tempPath, includePosition); - protections = fileProtections.Select(kvp => kvp.Key.Substring(tempPath.Length) + ": " + kvp.Value.TrimEnd()).ToList(); + var protections = subScanner.GetProtections(); // If temp directory cleanup fails try diff --git a/BurnOutSharp/Scanner.cs b/BurnOutSharp/Scanner.cs index 8c2a2496..29eddec6 100644 --- a/BurnOutSharp/Scanner.cs +++ b/BurnOutSharp/Scanner.cs @@ -17,11 +17,6 @@ namespace BurnOutSharp /// public IProgress FileProgress { get; set; } = null; - /// - /// List of paths that will be scanned with this object - /// - public List Paths { get; set; } = new List(); - /// /// Determines whether the byte position of found protection is included or not /// @@ -40,39 +35,35 @@ namespace BurnOutSharp /// /// Constructor /// - /// Path to create a scanner for /// Optional progress callback - public Scanner(string path, IProgress fileProgress = null) + public Scanner(IProgress fileProgress = null) { - Paths = new List { path }; FileProgress = fileProgress; } /// - /// Constructor + /// Scan a single path and get all found protections /// - /// Paths to create a scanner for - /// Optional progress callback - public Scanner(List paths, IProgress fileProgress = null) + /// Path to scan + /// Dictionary of list of strings representing the found protections + public Dictionary> GetProtections(string path) { - Paths = paths; - FileProgress = fileProgress; + return GetProtections(new List { path }); } /// /// Scan the list of paths and get all found protections /// /// Dictionary of list of strings representing the found protections - /// TODO: Should this populate an internal field instead of returning? - public Dictionary> GetProtections() + public Dictionary> GetProtections(List paths) { // If we have no paths, we can't scan - if (Paths == null || !Paths.Any()) + if (paths == null || !paths.Any()) return null; // Loop through each path and get the returned values var protections = new Dictionary>(); - foreach (string path in Paths) + foreach (string path in paths) { // Directories scan each internal file individually if (Directory.Exists(path)) @@ -459,13 +450,13 @@ namespace BurnOutSharp #region Archive File Types // If we're scanning archives, we have a few to try out - // TODO: All archives should return a dictionary instead of a list + // TODO: All archives should prefix internal paths properly if (ScanArchives) { // 7-Zip archive if (SevenZip.ShouldScan(magic)) { - var subProtections = SevenZip.Scan(this, fs, IncludePosition); + var subProtections = SevenZip.Scan(this, fs); if (!protections.ContainsKey(file)) protections[file] = new List(); @@ -475,7 +466,7 @@ namespace BurnOutSharp // BFPK archive if (BFPK.ShouldScan(magic)) { - var subProtections = BFPK.Scan(this, fs, IncludePosition); + var subProtections = BFPK.Scan(this, fs); if (!protections.ContainsKey(file)) protections[file] = new List(); @@ -485,7 +476,7 @@ namespace BurnOutSharp // BZip2 if (BZip2.ShouldScan(magic)) { - var subProtections = BZip2.Scan(this, fs, IncludePosition); + var subProtections = BZip2.Scan(this, fs); if (!protections.ContainsKey(file)) protections[file] = new List(); @@ -495,7 +486,7 @@ namespace BurnOutSharp // GZIP if (GZIP.ShouldScan(magic)) { - var subProtections = GZIP.Scan(this, fs, IncludePosition); + var subProtections = GZIP.Scan(this, fs); if (!protections.ContainsKey(file)) protections[file] = new List(); @@ -505,7 +496,7 @@ namespace BurnOutSharp // InstallShield Cabinet if (file != null && InstallShieldCAB.ShouldScan(magic)) { - var subProtections = InstallShieldCAB.Scan(this, file, IncludePosition); + var subProtections = InstallShieldCAB.Scan(this, file); if (!protections.ContainsKey(file)) protections[file] = new List(); @@ -515,7 +506,7 @@ namespace BurnOutSharp // Microsoft Cabinet if (file != null && MicrosoftCAB.ShouldScan(magic)) { - var subProtections = MicrosoftCAB.Scan(this, file, IncludePosition); + var subProtections = MicrosoftCAB.Scan(this, file); if (!protections.ContainsKey(file)) protections[file] = new List(); @@ -525,7 +516,7 @@ namespace BurnOutSharp // MSI if (file != null && MSI.ShouldScan(magic)) { - var subProtections = MSI.Scan(this, file, IncludePosition); + var subProtections = MSI.Scan(this, file); if (!protections.ContainsKey(file)) protections[file] = new List(); @@ -535,7 +526,7 @@ namespace BurnOutSharp // MPQ archive if (file != null && MPQ.ShouldScan(magic)) { - var subProtections = MPQ.Scan(this, file, IncludePosition); + var subProtections = MPQ.Scan(this, file); if (!protections.ContainsKey(file)) protections[file] = new List(); @@ -545,7 +536,7 @@ namespace BurnOutSharp // PKZIP archive (and derivatives) if (PKZIP.ShouldScan(magic)) { - var subProtections = PKZIP.Scan(this, fs, IncludePosition); + var subProtections = PKZIP.Scan(this, fs); if (!protections.ContainsKey(file)) protections[file] = new List(); @@ -555,7 +546,7 @@ namespace BurnOutSharp // RAR archive if (RAR.ShouldScan(magic)) { - var subProtections = RAR.Scan(this, fs, IncludePosition); + var subProtections = RAR.Scan(this, fs); if (!protections.ContainsKey(file)) protections[file] = new List(); @@ -565,7 +556,7 @@ namespace BurnOutSharp // Tape Archive if (TapeArchive.ShouldScan(magic)) { - var subProtections = TapeArchive.Scan(this, fs, IncludePosition); + var subProtections = TapeArchive.Scan(this, fs); if (!protections.ContainsKey(file)) protections[file] = new List(); @@ -575,7 +566,7 @@ namespace BurnOutSharp // Valve archive formats if (file != null && Valve.ShouldScan(magic)) { - var subProtections = Valve.Scan(this, file, IncludePosition); + var subProtections = Valve.Scan(this, file); if (!protections.ContainsKey(file)) protections[file] = new List(); @@ -585,7 +576,7 @@ namespace BurnOutSharp // XZ if (XZ.ShouldScan(magic)) { - var subProtections = XZ.Scan(this, fs, IncludePosition); + var subProtections = XZ.Scan(this, fs); if (!protections.ContainsKey(file)) protections[file] = new List();