diff --git a/BinaryObjectScanner/FileType/BFPK.cs b/BinaryObjectScanner/FileType/BFPK.cs index 70fc4b04..4b7406e3 100644 --- a/BinaryObjectScanner/FileType/BFPK.cs +++ b/BinaryObjectScanner/FileType/BFPK.cs @@ -13,16 +13,8 @@ namespace BinaryObjectScanner.FileType /// public override bool Extract(Stream? stream, string file, string outDir, bool includeDebug) { - // Create the wrapper - var bfpk = SabreTools.Serialization.Wrappers.BFPK.Create(stream); - if (bfpk == null) - return false; - - // Extract all files Directory.CreateDirectory(outDir); - bfpk.Extract(outDir, includeDebug); - - return true; + return _wrapper.Extract(outDir, includeDebug); } } } diff --git a/BinaryObjectScanner/FileType/BSP.cs b/BinaryObjectScanner/FileType/BSP.cs index 07d2344f..438463dd 100644 --- a/BinaryObjectScanner/FileType/BSP.cs +++ b/BinaryObjectScanner/FileType/BSP.cs @@ -13,18 +13,8 @@ namespace BinaryObjectScanner.FileType /// public override bool Extract(Stream? stream, string file, string outDir, bool includeDebug) { - // Create the wrapper - var bsp = SabreTools.Serialization.Wrappers.BSP.Create(stream); - if (bsp == null) - return false; - - // TODO: Introduce helper methods for all specialty lump types - - // Loop through and extract all files Directory.CreateDirectory(outDir); - bsp.Extract(outDir, includeDebug); - - return true; + return _wrapper.Extract(outDir, includeDebug); } } } diff --git a/BinaryObjectScanner/FileType/BZip2.cs b/BinaryObjectScanner/FileType/BZip2.cs index 23c6ee9f..33ee8498 100644 --- a/BinaryObjectScanner/FileType/BZip2.cs +++ b/BinaryObjectScanner/FileType/BZip2.cs @@ -13,20 +13,8 @@ namespace BinaryObjectScanner.FileType /// public override bool Extract(Stream? stream, string file, string outDir, bool includeDebug) { - // Handle invalid inputs - if (stream == null || stream.Length == 0) - return false; - - // Create the wrapper - var bzip = SabreTools.Serialization.Wrappers.BZip2.Create(stream); - if (bzip == null) - return false; - - // Loop through and extract all files Directory.CreateDirectory(outDir); - bzip.Extract(outDir, includeDebug); - - return true; + return _wrapper.Extract(outDir, includeDebug); } } } diff --git a/BinaryObjectScanner/FileType/CFB.cs b/BinaryObjectScanner/FileType/CFB.cs index 39f84154..22165d2b 100644 --- a/BinaryObjectScanner/FileType/CFB.cs +++ b/BinaryObjectScanner/FileType/CFB.cs @@ -13,16 +13,8 @@ namespace BinaryObjectScanner.FileType /// public override bool Extract(Stream? stream, string file, string outDir, bool includeDebug) { - // Create the wrapper - var cfb = SabreTools.Serialization.Wrappers.CFB.Create(stream); - if (cfb == null) - return false; - - // Loop through and extract all files Directory.CreateDirectory(outDir); - cfb.Extract(outDir, includeDebug); - - return true; + return _wrapper.Extract(outDir, includeDebug); } } } diff --git a/BinaryObjectScanner/FileType/DetectableExtractableBase.cs b/BinaryObjectScanner/FileType/DetectableExtractableBase.cs new file mode 100644 index 00000000..fa92feb2 --- /dev/null +++ b/BinaryObjectScanner/FileType/DetectableExtractableBase.cs @@ -0,0 +1,51 @@ +using System.IO; +using BinaryObjectScanner.Interfaces; + +namespace BinaryObjectScanner.FileType +{ + /// + /// Base class for all standard detectable/extractable types + /// + public abstract class DetectableExtractableBase : IDetectable, IExtractable + { + #region Constructors + + public DetectableExtractableBase() { } + + #endregion + + #region IDetectable Implementations + + /// + public string? Detect(string file, bool includeDebug) + { + if (!File.Exists(file)) + return null; + + using var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); + return Detect(fs, file, includeDebug); + } + + /// + public abstract string? Detect(Stream stream, string file, bool includeDebug); + + #endregion + + #region IExtractable Implementations + + /// + public bool Extract(string file, string outDir, bool includeDebug) + { + if (!File.Exists(file)) + return false; + + using var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); + return Extract(fs, file, outDir, includeDebug); + } + + /// + public abstract bool Extract(Stream? stream, string file, string outDir, bool includeDebug); + + #endregion + } +} \ No newline at end of file diff --git a/BinaryObjectScanner/FileType/DetectableExtractableBaseT.cs b/BinaryObjectScanner/FileType/DetectableExtractableBaseT.cs new file mode 100644 index 00000000..0a38d2c9 --- /dev/null +++ b/BinaryObjectScanner/FileType/DetectableExtractableBaseT.cs @@ -0,0 +1,34 @@ +using System; +using BinaryObjectScanner.Interfaces; +using SabreTools.Serialization.Interfaces; + +namespace BinaryObjectScanner.FileType +{ + /// + /// Base class for all standard detectable/extractable types with a wrapper + /// + public abstract class DetectableExtractableBase : DetectableExtractableBase, IDetectable, IExtractable + where T : IWrapper + { + #region Protected Instance Variables + + /// + /// Wrapper representing the detectable/extractable + /// + protected T _wrapper { get; private set; } + + #endregion + + #region Constructors + + public DetectableExtractableBase(T? wrapper) + { + if (wrapper == null) + throw new ArgumentNullException(nameof(wrapper)); + + _wrapper = wrapper; + } + + #endregion + } +} \ No newline at end of file diff --git a/BinaryObjectScanner/FileType/Executable.cs b/BinaryObjectScanner/FileType/Executable.cs index b3cb1dd8..e53a74e9 100644 --- a/BinaryObjectScanner/FileType/Executable.cs +++ b/BinaryObjectScanner/FileType/Executable.cs @@ -11,7 +11,7 @@ namespace BinaryObjectScanner.FileType /// /// Executable or library /// - public abstract class Executable : DetectableBase + public abstract class Executable : DetectableExtractableBase where T : WrapperBase { /// diff --git a/BinaryObjectScanner/FileType/GCF.cs b/BinaryObjectScanner/FileType/GCF.cs index 689750f1..858e5629 100644 --- a/BinaryObjectScanner/FileType/GCF.cs +++ b/BinaryObjectScanner/FileType/GCF.cs @@ -13,16 +13,8 @@ namespace BinaryObjectScanner.FileType /// public override bool Extract(Stream? stream, string file, string outDir, bool includeDebug) { - // Create the wrapper - var gcf = SabreTools.Serialization.Wrappers.GCF.Create(stream); - if (gcf == null) - return false; - - // Loop through and extract all files Directory.CreateDirectory(outDir); - gcf.Extract(outDir, includeDebug); - - return true; + return _wrapper.Extract(outDir, includeDebug); } } } diff --git a/BinaryObjectScanner/FileType/GZip.cs b/BinaryObjectScanner/FileType/GZip.cs index a0d61592..ec982c59 100644 --- a/BinaryObjectScanner/FileType/GZip.cs +++ b/BinaryObjectScanner/FileType/GZip.cs @@ -13,16 +13,8 @@ namespace BinaryObjectScanner.FileType /// public override bool Extract(Stream? stream, string file, string outDir, bool includeDebug) { - // Create the wrapper - var gcf = SabreTools.Serialization.Wrappers.GZip.Create(stream); - if (gcf == null) - return false; - - // Loop through and extract all files Directory.CreateDirectory(outDir); - gcf.Extract(outDir, includeDebug); - - return true; + return _wrapper.Extract(outDir, includeDebug); } } } diff --git a/BinaryObjectScanner/FileType/InstallShieldArchiveV3.cs b/BinaryObjectScanner/FileType/InstallShieldArchiveV3.cs index ded3763b..220f0935 100644 --- a/BinaryObjectScanner/FileType/InstallShieldArchiveV3.cs +++ b/BinaryObjectScanner/FileType/InstallShieldArchiveV3.cs @@ -13,16 +13,8 @@ namespace BinaryObjectScanner.FileType /// public override bool Extract(Stream? stream, string file, string outDir, bool includeDebug) { - // Create the wrapper - var isv3 = SabreTools.Serialization.Wrappers.InstallShieldArchiveV3.Create(stream); - if (isv3 == null) - return false; - - // Loop through and extract all files Directory.CreateDirectory(outDir); - isv3.Extract(outDir, includeDebug); - - return true; + return _wrapper.Extract(outDir, includeDebug); } } } diff --git a/BinaryObjectScanner/FileType/InstallShieldCAB.cs b/BinaryObjectScanner/FileType/InstallShieldCAB.cs index 1ed38d64..77459710 100644 --- a/BinaryObjectScanner/FileType/InstallShieldCAB.cs +++ b/BinaryObjectScanner/FileType/InstallShieldCAB.cs @@ -13,16 +13,8 @@ namespace BinaryObjectScanner.FileType /// public override bool Extract(Stream? stream, string file, string outDir, bool includeDebug) { - // Create the wrapper - var iscab = SabreTools.Serialization.Wrappers.InstallShieldCabinet.Create(stream); - if (iscab == null) - return false; - - // Loop through and extract all files Directory.CreateDirectory(outDir); - iscab.Extract(outDir, includeDebug); - - return true; + return _wrapper.Extract(outDir, includeDebug); } } } diff --git a/BinaryObjectScanner/FileType/LZKWAJ.cs b/BinaryObjectScanner/FileType/LZKWAJ.cs index 2f90b0cb..1e2dc666 100644 --- a/BinaryObjectScanner/FileType/LZKWAJ.cs +++ b/BinaryObjectScanner/FileType/LZKWAJ.cs @@ -13,16 +13,8 @@ namespace BinaryObjectScanner.FileType /// public override bool Extract(Stream? stream, string file, string outDir, bool includeDebug) { - // Create the wrapper - var kwaj = SabreTools.Serialization.Wrappers.LZKWAJ.Create(stream); - if (kwaj == null) - return false; - - // Loop through and extract all files Directory.CreateDirectory(outDir); - kwaj.Extract(outDir, includeDebug); - - return true; + return _wrapper.Extract(outDir, includeDebug); } } } diff --git a/BinaryObjectScanner/FileType/LZQBasic.cs b/BinaryObjectScanner/FileType/LZQBasic.cs index 1dc8eed8..5228ebff 100644 --- a/BinaryObjectScanner/FileType/LZQBasic.cs +++ b/BinaryObjectScanner/FileType/LZQBasic.cs @@ -13,16 +13,8 @@ namespace BinaryObjectScanner.FileType /// public override bool Extract(Stream? stream, string file, string outDir, bool includeDebug) { - // Create the wrapper - var qbasic = SabreTools.Serialization.Wrappers.LZQBasic.Create(stream); - if (qbasic == null) - return false; - - // Loop through and extract all files Directory.CreateDirectory(outDir); - qbasic.Extract(outDir, includeDebug); - - return true; + return _wrapper.Extract(outDir, includeDebug); } } } diff --git a/BinaryObjectScanner/FileType/LZSZDD.cs b/BinaryObjectScanner/FileType/LZSZDD.cs index 3e3f3066..12217562 100644 --- a/BinaryObjectScanner/FileType/LZSZDD.cs +++ b/BinaryObjectScanner/FileType/LZSZDD.cs @@ -13,16 +13,8 @@ namespace BinaryObjectScanner.FileType /// public override bool Extract(Stream? stream, string file, string outDir, bool includeDebug) { - // Create the wrapper - var szdd = SabreTools.Serialization.Wrappers.LZSZDD.Create(stream); - if (szdd == null) - return false; - - // Loop through and extract all files Directory.CreateDirectory(outDir); - szdd.Extract(outDir, includeDebug); - - return true; + return _wrapper.Extract(outDir, includeDebug); } } } diff --git a/BinaryObjectScanner/FileType/LinearExecutable.cs b/BinaryObjectScanner/FileType/LinearExecutable.cs index 7bb2f860..6f36bde8 100644 --- a/BinaryObjectScanner/FileType/LinearExecutable.cs +++ b/BinaryObjectScanner/FileType/LinearExecutable.cs @@ -43,5 +43,8 @@ namespace BinaryObjectScanner.FileType return string.Join(";", [.. protectionList]); } + + /// + public override bool Extract(Stream? stream, string file, string outDir, bool includeDebug) => false; } } diff --git a/BinaryObjectScanner/FileType/MPQ.cs b/BinaryObjectScanner/FileType/MPQ.cs index a71fd72d..ec5f2a2f 100644 --- a/BinaryObjectScanner/FileType/MPQ.cs +++ b/BinaryObjectScanner/FileType/MPQ.cs @@ -13,16 +13,8 @@ namespace BinaryObjectScanner.FileType /// public override bool Extract(Stream? stream, string file, string outDir, bool includeDebug) { - // Create the wrapper - var mpq = SabreTools.Serialization.Wrappers.MoPaQ.Create(stream); - if (mpq == null) - return false; - - // Loop through and extract all files Directory.CreateDirectory(outDir); - mpq.Extract(outDir, includeDebug); - - return true; + return _wrapper.Extract(outDir, includeDebug); } } } diff --git a/BinaryObjectScanner/FileType/MSDOS.cs b/BinaryObjectScanner/FileType/MSDOS.cs index 56983a06..a33254c7 100644 --- a/BinaryObjectScanner/FileType/MSDOS.cs +++ b/BinaryObjectScanner/FileType/MSDOS.cs @@ -43,5 +43,8 @@ namespace BinaryObjectScanner.FileType return string.Join(";", [.. protectionList]); } + + /// + public override bool Extract(Stream? stream, string file, string outDir, bool includeDebug) => false; } } diff --git a/BinaryObjectScanner/FileType/MicrosoftCAB.cs b/BinaryObjectScanner/FileType/MicrosoftCAB.cs index 3b978ed6..c4144c46 100644 --- a/BinaryObjectScanner/FileType/MicrosoftCAB.cs +++ b/BinaryObjectScanner/FileType/MicrosoftCAB.cs @@ -13,16 +13,8 @@ namespace BinaryObjectScanner.FileType /// public override bool Extract(Stream? stream, string file, string outDir, bool includeDebug) { - // Create the wrapper - var mscab = SabreTools.Serialization.Wrappers.MicrosoftCabinet.Create(stream); - if (mscab == null) - return false; - - // Loop through and extract all files Directory.CreateDirectory(outDir); - mscab.Extract(outDir, includeDebug); - - return true; + return _wrapper.Extract(outDir, includeDebug); } } } diff --git a/BinaryObjectScanner/FileType/NewExecutable.cs b/BinaryObjectScanner/FileType/NewExecutable.cs index 24568a9e..a4ea5988 100644 --- a/BinaryObjectScanner/FileType/NewExecutable.cs +++ b/BinaryObjectScanner/FileType/NewExecutable.cs @@ -1,14 +1,13 @@ using System.Collections.Generic; using System.IO; using BinaryObjectScanner.Data; -using BinaryObjectScanner.Interfaces; namespace BinaryObjectScanner.FileType { /// /// New executable (NE) /// - public class NewExecutable : Executable, IExtractable + public class NewExecutable : Executable { /// public NewExecutable(SabreTools.Serialization.Wrappers.NewExecutable? wrapper) : base(wrapper) { } @@ -46,12 +45,7 @@ namespace BinaryObjectScanner.FileType } /// - /// Uses the already-generated wrapper - public bool Extract(string file, string outDir, bool includeDebug) - => Extract(null, file, outDir, includeDebug); - - /// - public bool Extract(Stream? stream, string file, string outDir, bool includeDebug) + public override bool Extract(Stream? stream, string file, string outDir, bool includeDebug) { // Create the output directory Directory.CreateDirectory(outDir); diff --git a/BinaryObjectScanner/FileType/PAK.cs b/BinaryObjectScanner/FileType/PAK.cs index e9867c42..8b149b19 100644 --- a/BinaryObjectScanner/FileType/PAK.cs +++ b/BinaryObjectScanner/FileType/PAK.cs @@ -13,16 +13,8 @@ namespace BinaryObjectScanner.FileType /// public override bool Extract(Stream? stream, string file, string outDir, bool includeDebug) { - // Create the wrapper - var pak = SabreTools.Serialization.Wrappers.PAK.Create(stream); - if (pak == null) - return false; - - // Loop through and extract all files Directory.CreateDirectory(outDir); - pak.Extract(outDir, includeDebug); - - return true; + return _wrapper.Extract(outDir, includeDebug); } } } diff --git a/BinaryObjectScanner/FileType/PFF.cs b/BinaryObjectScanner/FileType/PFF.cs index 7fbf944a..2d78e901 100644 --- a/BinaryObjectScanner/FileType/PFF.cs +++ b/BinaryObjectScanner/FileType/PFF.cs @@ -13,16 +13,8 @@ namespace BinaryObjectScanner.FileType /// public override bool Extract(Stream? stream, string file, string outDir, bool includeDebug) { - // Create the wrapper - var pff = SabreTools.Serialization.Wrappers.PFF.Create(stream); - if (pff == null) - return false; - - // Extract all files Directory.CreateDirectory(outDir); - pff.Extract(outDir, includeDebug); - - return true; + return _wrapper.Extract(outDir, includeDebug); } } } diff --git a/BinaryObjectScanner/FileType/PKZIP.cs b/BinaryObjectScanner/FileType/PKZIP.cs index c7b8ab01..bba58c53 100644 --- a/BinaryObjectScanner/FileType/PKZIP.cs +++ b/BinaryObjectScanner/FileType/PKZIP.cs @@ -13,16 +13,8 @@ namespace BinaryObjectScanner.FileType /// public override bool Extract(Stream? stream, string file, string outDir, bool includeDebug) { - // Create the wrapper - var pkzip = SabreTools.Serialization.Wrappers.PKZIP.Create(stream); - if (pkzip == null) - return false; - - // Loop through and extract all files Directory.CreateDirectory(outDir); - pkzip.Extract(outDir, includeDebug); - - return true; + return _wrapper.Extract(outDir, includeDebug); } } } diff --git a/BinaryObjectScanner/FileType/PortableExecutable.cs b/BinaryObjectScanner/FileType/PortableExecutable.cs index 53f48bae..a63ab5fb 100644 --- a/BinaryObjectScanner/FileType/PortableExecutable.cs +++ b/BinaryObjectScanner/FileType/PortableExecutable.cs @@ -1,14 +1,13 @@ using System.Collections.Generic; using System.IO; using BinaryObjectScanner.Data; -using BinaryObjectScanner.Interfaces; namespace BinaryObjectScanner.FileType { /// /// Portable executable (PE) /// - public class PortableExecutable : Executable, IExtractable + public class PortableExecutable : Executable { /// public PortableExecutable(SabreTools.Serialization.Wrappers.PortableExecutable? wrapper) : base(wrapper) { } @@ -46,12 +45,7 @@ namespace BinaryObjectScanner.FileType } /// - /// Uses the already-generated wrapper - public bool Extract(string file, string outDir, bool includeDebug) - => Extract(null, file, outDir, includeDebug); - - /// - public bool Extract(Stream? stream, string file, string outDir, bool includeDebug) + public override bool Extract(Stream? stream, string file, string outDir, bool includeDebug) { // Create the output directory Directory.CreateDirectory(outDir); diff --git a/BinaryObjectScanner/FileType/Quantum.cs b/BinaryObjectScanner/FileType/Quantum.cs index dfd88d0a..8dfbc6b8 100644 --- a/BinaryObjectScanner/FileType/Quantum.cs +++ b/BinaryObjectScanner/FileType/Quantum.cs @@ -13,16 +13,8 @@ namespace BinaryObjectScanner.FileType /// public override bool Extract(Stream? stream, string file, string outDir, bool includeDebug) { - // Create the wrapper - var qtm = SabreTools.Serialization.Wrappers.Quantum.Create(stream); - if (qtm == null) - return false; - - // Loop through and extract all files Directory.CreateDirectory(outDir); - qtm.Extract(outDir, includeDebug); - - return true; + return _wrapper.Extract(outDir, includeDebug); } } } diff --git a/BinaryObjectScanner/FileType/RAR.cs b/BinaryObjectScanner/FileType/RAR.cs index 2f76bb02..8524b4d3 100644 --- a/BinaryObjectScanner/FileType/RAR.cs +++ b/BinaryObjectScanner/FileType/RAR.cs @@ -13,20 +13,8 @@ namespace BinaryObjectScanner.FileType /// public override bool Extract(Stream? stream, string file, string outDir, bool includeDebug) { - // Handle invalid inputs - if (stream == null || stream.Length == 0) - return false; - - // Create the wrapper - var rar = SabreTools.Serialization.Wrappers.RAR.Create(stream); - if (rar == null) - return false; - - // Loop through and extract all files Directory.CreateDirectory(outDir); - rar.Extract(outDir, includeDebug); - - return true; + return _wrapper.Extract(outDir, includeDebug); } } } \ No newline at end of file diff --git a/BinaryObjectScanner/FileType/SFFS.cs b/BinaryObjectScanner/FileType/SFFS.cs index 4e6650f4..8074599f 100644 --- a/BinaryObjectScanner/FileType/SFFS.cs +++ b/BinaryObjectScanner/FileType/SFFS.cs @@ -1,6 +1,5 @@ using System; using System.IO; -using BinaryObjectScanner.Interfaces; using SabreTools.Matching; namespace BinaryObjectScanner.FileType @@ -9,7 +8,7 @@ namespace BinaryObjectScanner.FileType /// StarForce Filesystem file /// /// - public class SFFS : DetectableBase, IExtractable + public class SFFS : DetectableExtractableBase { /// public override string? Detect(Stream stream, string file, bool includeDebug) @@ -31,17 +30,7 @@ namespace BinaryObjectScanner.FileType } /// - public bool Extract(string file, string outDir, bool includeDebug) - { - if (!File.Exists(file)) - return false; - - using var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); - return Extract(fs, file, outDir, includeDebug); - } - - /// - public bool Extract(Stream? stream, string file, string outDir, bool includeDebug) + public override bool Extract(Stream? stream, string file, string outDir, bool includeDebug) { return false; } diff --git a/BinaryObjectScanner/FileType/SGA.cs b/BinaryObjectScanner/FileType/SGA.cs index 420c798d..1ab7f168 100644 --- a/BinaryObjectScanner/FileType/SGA.cs +++ b/BinaryObjectScanner/FileType/SGA.cs @@ -13,16 +13,8 @@ namespace BinaryObjectScanner.FileType /// public override bool Extract(Stream? stream, string file, string outDir, bool includeDebug) { - // Create the wrapper - var sga = SabreTools.Serialization.Wrappers.SGA.Create(stream); - if (sga == null) - return false; - - // Loop through and extract all files Directory.CreateDirectory(outDir); - sga.Extract(outDir, includeDebug); - - return true; + return _wrapper.Extract(outDir, includeDebug); } } } diff --git a/BinaryObjectScanner/FileType/SevenZip.cs b/BinaryObjectScanner/FileType/SevenZip.cs index 8553acce..206d0713 100644 --- a/BinaryObjectScanner/FileType/SevenZip.cs +++ b/BinaryObjectScanner/FileType/SevenZip.cs @@ -13,20 +13,8 @@ namespace BinaryObjectScanner.FileType /// public override bool Extract(Stream? stream, string file, string outDir, bool includeDebug) { - // Handle invalid inputs - if (stream == null || stream.Length == 0) - return false; - - // Create the wrapper - var sevenZip = SabreTools.Serialization.Wrappers.SevenZip.Create(stream); - if (sevenZip == null) - return false; - - // Loop through and extract all files Directory.CreateDirectory(outDir); - sevenZip.Extract(outDir, includeDebug); - - return true; + return _wrapper.Extract(outDir, includeDebug); } } } \ No newline at end of file diff --git a/BinaryObjectScanner/FileType/TapeArchive.cs b/BinaryObjectScanner/FileType/TapeArchive.cs index bbd164eb..327cbaca 100644 --- a/BinaryObjectScanner/FileType/TapeArchive.cs +++ b/BinaryObjectScanner/FileType/TapeArchive.cs @@ -13,16 +13,8 @@ namespace BinaryObjectScanner.FileType /// public override bool Extract(Stream? stream, string file, string outDir, bool includeDebug) { - // Create the wrapper - var tar = SabreTools.Serialization.Wrappers.TapeArchive.Create(stream); - if (tar == null) - return false; - - // Loop through and extract all files Directory.CreateDirectory(outDir); - tar.Extract(outDir, includeDebug); - - return true; + return _wrapper.Extract(outDir, includeDebug); } } } diff --git a/BinaryObjectScanner/FileType/VBSP.cs b/BinaryObjectScanner/FileType/VBSP.cs index be0984c5..8f2c7d40 100644 --- a/BinaryObjectScanner/FileType/VBSP.cs +++ b/BinaryObjectScanner/FileType/VBSP.cs @@ -13,18 +13,8 @@ namespace BinaryObjectScanner.FileType /// public override bool Extract(Stream? stream, string file, string outDir, bool includeDebug) { - // Create the wrapper - var vbsp = SabreTools.Serialization.Wrappers.VBSP.Create(stream); - if (vbsp == null) - return false; - - // TODO: Introduce helper methods for all specialty lump types - - // Loop through and extract all files Directory.CreateDirectory(outDir); - vbsp.Extract(outDir, includeDebug); - - return true; + return _wrapper.Extract(outDir, includeDebug); } } } diff --git a/BinaryObjectScanner/FileType/VPK.cs b/BinaryObjectScanner/FileType/VPK.cs index e1583bd6..7a23268d 100644 --- a/BinaryObjectScanner/FileType/VPK.cs +++ b/BinaryObjectScanner/FileType/VPK.cs @@ -13,16 +13,8 @@ namespace BinaryObjectScanner.FileType /// public override bool Extract(Stream? stream, string file, string outDir, bool includeDebug) { - // Create the wrapper - var vpk = SabreTools.Serialization.Wrappers.VPK.Create(stream); - if (vpk == null) - return false; - - // Loop through and extract all files Directory.CreateDirectory(outDir); - vpk.Extract(outDir, includeDebug); - - return true; + return _wrapper.Extract(outDir, includeDebug); } } } diff --git a/BinaryObjectScanner/FileType/WAD3.cs b/BinaryObjectScanner/FileType/WAD3.cs index d56f7950..db942a20 100644 --- a/BinaryObjectScanner/FileType/WAD3.cs +++ b/BinaryObjectScanner/FileType/WAD3.cs @@ -13,16 +13,8 @@ namespace BinaryObjectScanner.FileType /// public override bool Extract(Stream? stream, string file, string outDir, bool includeDebug) { - // Create the wrapper - var wad = SabreTools.Serialization.Wrappers.WAD3.Create(stream); - if (wad == null) - return false; - - // Loop through and extract all files Directory.CreateDirectory(outDir); - wad.Extract(outDir, includeDebug); - - return true; + return _wrapper.Extract(outDir, includeDebug); } } } diff --git a/BinaryObjectScanner/FileType/XZ.cs b/BinaryObjectScanner/FileType/XZ.cs index 5715983c..76b8cc0b 100644 --- a/BinaryObjectScanner/FileType/XZ.cs +++ b/BinaryObjectScanner/FileType/XZ.cs @@ -13,20 +13,8 @@ namespace BinaryObjectScanner.FileType /// public override bool Extract(Stream? stream, string file, string outDir, bool includeDebug) { - // Handle invalid inputs - if (stream == null || stream.Length == 0) - return false; - - // Create the wrapper - var xz = SabreTools.Serialization.Wrappers.XZ.Create(stream); - if (xz == null) - return false; - - // Loop through and extract all files Directory.CreateDirectory(outDir); - xz.Extract(outDir, includeDebug); - - return true; + return _wrapper.Extract(outDir, includeDebug); } } } diff --git a/BinaryObjectScanner/FileType/XZP.cs b/BinaryObjectScanner/FileType/XZP.cs index 9cc9bb81..fe34bb03 100644 --- a/BinaryObjectScanner/FileType/XZP.cs +++ b/BinaryObjectScanner/FileType/XZP.cs @@ -13,16 +13,8 @@ namespace BinaryObjectScanner.FileType /// public override bool Extract(Stream? stream, string file, string outDir, bool includeDebug) { - // Create the wrapper - var xzp = SabreTools.Serialization.Wrappers.XZP.Create(stream); - if (xzp == null) - return false; - - // Loop through and extract all files Directory.CreateDirectory(outDir); - xzp.Extract(outDir, includeDebug); - - return true; + return _wrapper.Extract(outDir, includeDebug); } } }