From f998a578cc6f3f5eb002caa8685fb866d2a10fe8 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Mon, 4 Nov 2024 14:14:50 -0500 Subject: [PATCH] Make Extractor static like Protector --- Test/Extractor.cs | 36 +++++++----------------------------- Test/Program.cs | 5 +---- 2 files changed, 8 insertions(+), 33 deletions(-) diff --git a/Test/Extractor.cs b/Test/Extractor.cs index b52e057f..041a91de 100644 --- a/Test/Extractor.cs +++ b/Test/Extractor.cs @@ -5,50 +5,28 @@ using SabreTools.Serialization.Wrappers; namespace Test { - internal class Extractor + internal static class Extractor { - #region Options - - /// - /// Determines if debug information is output or not - /// - private bool _includeDebug; - - #endregion - - /// - /// Constructor - /// - /// Enable including debug information - public Extractor(bool includeDebug) - { - _includeDebug = includeDebug; - -#if NET462_OR_GREATER || NETCOREAPP - // Register the codepages - System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance); -#endif - } - /// /// Wrapper to extract data for a single path /// /// File or directory path /// Output directory path - public void ExtractPath(string path, string outputDirectory) + /// Enable including debug information + public static void ExtractPath(string path, string outputDirectory, bool includeDebug) { Console.WriteLine($"Checking possible path: {path}"); // Check if the file or directory exists if (File.Exists(path)) { - ExtractFile(path, outputDirectory); + ExtractFile(path, outputDirectory, includeDebug); } else if (Directory.Exists(path)) { foreach (string file in IOExtensions.SafeEnumerateFiles(path, "*", SearchOption.AllDirectories)) { - ExtractFile(file, outputDirectory); + ExtractFile(file, outputDirectory, includeDebug); } } else @@ -60,7 +38,7 @@ namespace Test /// /// Print information for a single file, if possible /// - private void ExtractFile(string file, string outputDirectory) + private static void ExtractFile(string file, string outputDirectory, bool includeDebug) { Console.WriteLine($"Attempting to extract all files from {file}"); using Stream stream = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); @@ -77,7 +55,7 @@ namespace Test } catch (Exception ex) { - if (_includeDebug) Console.WriteLine(ex); + if (includeDebug) Console.WriteLine(ex); return; } diff --git a/Test/Program.cs b/Test/Program.cs index fb30a96f..a7083ecf 100644 --- a/Test/Program.cs +++ b/Test/Program.cs @@ -26,9 +26,6 @@ namespace Test return; } - // Create extractor for all paths - var extractor = new Extractor(options.Debug); - // Create scanner for all paths var scanner = new Scanner( options.ScanArchives, @@ -44,7 +41,7 @@ namespace Test { // Extraction if (options.EnableExtraction) - extractor.ExtractPath(inputPath, options.OutputPath); + Extractor.ExtractPath(inputPath, options.OutputPath, options.Debug); // Scanning if (options.EnableScanning)