diff --git a/BinaryObjectScanner.Test/FactoryTests.cs b/BinaryObjectScanner.Test/FactoryTests.cs index 106a963a..005f6f8d 100644 --- a/BinaryObjectScanner.Test/FactoryTests.cs +++ b/BinaryObjectScanner.Test/FactoryTests.cs @@ -58,39 +58,39 @@ namespace BinaryObjectScanner.Test private static readonly List _extractableTypes = [ - WrapperType.BFPK, - WrapperType.BSP, - WrapperType.BZip2, - WrapperType.CFB, - //WrapperType.CIA, - //WrapperType.Executable, // TODO: This needs to be split internally - WrapperType.GCF, - WrapperType.GZip, - WrapperType.InstallShieldArchiveV3, - WrapperType.InstallShieldCAB, - WrapperType.LZKWAJ, - WrapperType.LZQBasic, - WrapperType.LZSZDD, - WrapperType.MicrosoftCAB, - WrapperType.MoPaQ, - //WrapperType.N3DS, - //WrapperType.NCF, - //WrapperType.Nitro, - WrapperType.PAK, - WrapperType.PFF, - WrapperType.PKZIP, - //WrapperType.PlayJAudioFile, // TODO: Create wrapper to reenable test - //WrapperType.Quantum, - WrapperType.RAR, - WrapperType.SevenZip, + // WrapperType.BFPK, // TODO: Create wrapper to reenable test + // WrapperType.BSP, // TODO: Create wrapper to reenable test + // WrapperType.BZip2, // TODO: Create wrapper to reenable test + // WrapperType.CFB, // TODO: Create wrapper to reenable test + // WrapperType.CIA, + // WrapperType.Executable, // TODO: This needs to be split internally + // WrapperType.GCF, // TODO: Create wrapper to reenable test + // WrapperType.GZip, // TODO: Create wrapper to reenable test + // WrapperType.InstallShieldArchiveV3, // TODO: Create wrapper to reenable test + // WrapperType.InstallShieldCAB, // TODO: Create wrapper to reenable test + // WrapperType.LZKWAJ, // TODO: Create wrapper to reenable test + // WrapperType.LZQBasic, // TODO: Create wrapper to reenable test + // WrapperType.LZSZDD, // TODO: Create wrapper to reenable test + // WrapperType.MicrosoftCAB, // TODO: Create wrapper to reenable test + // WrapperType.MoPaQ, // TODO: Create wrapper to reenable test + // WrapperType.N3DS, + // WrapperType.NCF, + // WrapperType.Nitro, + // WrapperType.PAK, // TODO: Create wrapper to reenable test + // WrapperType.PFF, // TODO: Create wrapper to reenable test + // WrapperType.PKZIP, // TODO: Create wrapper to reenable test + // WrapperType.PlayJAudioFile, // TODO: Create wrapper to reenable test + // WrapperType.Quantum, // TODO: Create wrapper to reenable test + // WrapperType.RAR, // TODO: Create wrapper to reenable test + // WrapperType.SevenZip, // TODO: Create wrapper to reenable test WrapperType.SFFS, - WrapperType.SGA, - WrapperType.TapeArchive, - WrapperType.VBSP, - WrapperType.VPK, - WrapperType.WAD, - WrapperType.XZ, - WrapperType.XZP, + // WrapperType.SGA, // TODO: Create wrapper to reenable test + // WrapperType.TapeArchive, // TODO: Create wrapper to reenable test + // WrapperType.VBSP, // TODO: Create wrapper to reenable test + // WrapperType.VPK, // TODO: Create wrapper to reenable test + // WrapperType.WAD, // TODO: Create wrapper to reenable test + // WrapperType.XZ, // TODO: Create wrapper to reenable test + // WrapperType.XZP, // TODO: Create wrapper to reenable test ]; [Theory] diff --git a/BinaryObjectScanner.Test/FileType/BFPKTests.cs b/BinaryObjectScanner.Test/FileType/BFPKTests.cs index b4a87679..2f5f7f04 100644 --- a/BinaryObjectScanner.Test/FileType/BFPKTests.cs +++ b/BinaryObjectScanner.Test/FileType/BFPKTests.cs @@ -6,12 +6,15 @@ namespace BinaryObjectScanner.Test.FileType { public class BFPKTests { + private static readonly SabreTools.Serialization.Wrappers.BFPK wrapper + = new(new SabreTools.Models.BFPK.Archive(), new MemoryStream()); + [Fact] public void ExtractFile_EmptyString_False() { string file = string.Empty; string outDir = string.Empty; - var extractable = new BFPK(); + var extractable = new BFPK(wrapper); bool actual = extractable.Extract(file, outDir, includeDebug: false); Assert.False(actual); @@ -23,7 +26,7 @@ namespace BinaryObjectScanner.Test.FileType Stream? stream = null; string file = string.Empty; string outDir = string.Empty; - var extractable = new BFPK(); + var extractable = new BFPK(wrapper); bool actual = extractable.Extract(stream, file, outDir, includeDebug: false); Assert.False(actual); @@ -35,7 +38,7 @@ namespace BinaryObjectScanner.Test.FileType Stream? stream = new MemoryStream(); string file = string.Empty; string outDir = string.Empty; - var extractable = new BFPK(); + var extractable = new BFPK(wrapper); bool actual = extractable.Extract(stream, file, outDir, includeDebug: false); Assert.False(actual); diff --git a/BinaryObjectScanner.Test/FileType/BSPTests.cs b/BinaryObjectScanner.Test/FileType/BSPTests.cs index 40b05167..b80e1f52 100644 --- a/BinaryObjectScanner.Test/FileType/BSPTests.cs +++ b/BinaryObjectScanner.Test/FileType/BSPTests.cs @@ -6,12 +6,15 @@ namespace BinaryObjectScanner.Test.FileType { public class BSPTests { + private static readonly SabreTools.Serialization.Wrappers.BSP wrapper + = new(new SabreTools.Models.BSP.BspFile(), new MemoryStream()); + [Fact] public void ExtractFile_EmptyString_False() { string file = string.Empty; string outDir = string.Empty; - var extractable = new BSP(); + var extractable = new BSP(wrapper); bool actual = extractable.Extract(file, outDir, includeDebug: false); Assert.False(actual); @@ -23,7 +26,7 @@ namespace BinaryObjectScanner.Test.FileType Stream? stream = null; string file = string.Empty; string outDir = string.Empty; - var extractable = new BSP(); + var extractable = new BSP(wrapper); bool actual = extractable.Extract(stream, file, outDir, includeDebug: false); Assert.False(actual); @@ -35,7 +38,7 @@ namespace BinaryObjectScanner.Test.FileType Stream? stream = new MemoryStream(); string file = string.Empty; string outDir = string.Empty; - var extractable = new BSP(); + var extractable = new BSP(wrapper); bool actual = extractable.Extract(stream, file, outDir, includeDebug: false); Assert.False(actual); diff --git a/BinaryObjectScanner.Test/FileType/BZip2Tests.cs b/BinaryObjectScanner.Test/FileType/BZip2Tests.cs index 86182c9a..ed45547a 100644 --- a/BinaryObjectScanner.Test/FileType/BZip2Tests.cs +++ b/BinaryObjectScanner.Test/FileType/BZip2Tests.cs @@ -6,12 +6,15 @@ namespace BinaryObjectScanner.Test.FileType { public class BZip2Tests { + private static readonly SabreTools.Serialization.Wrappers.BZip2 wrapper + = new(new MemoryStream()); + [Fact] public void ExtractFile_EmptyString_False() { string file = string.Empty; string outDir = string.Empty; - var extractable = new BZip2(); + var extractable = new BZip2(wrapper); bool actual = extractable.Extract(file, outDir, includeDebug: false); Assert.False(actual); @@ -23,7 +26,7 @@ namespace BinaryObjectScanner.Test.FileType Stream? stream = null; string file = string.Empty; string outDir = string.Empty; - var extractable = new BZip2(); + var extractable = new BZip2(wrapper); bool actual = extractable.Extract(stream, file, outDir, includeDebug: false); Assert.False(actual); @@ -35,7 +38,7 @@ namespace BinaryObjectScanner.Test.FileType Stream? stream = new MemoryStream(); string file = string.Empty; string outDir = string.Empty; - var extractable = new BZip2(); + var extractable = new BZip2(wrapper); bool actual = extractable.Extract(stream, file, outDir, includeDebug: false); Assert.False(actual); diff --git a/BinaryObjectScanner.Test/FileType/CFBTests.cs b/BinaryObjectScanner.Test/FileType/CFBTests.cs index be5dea04..5871b96c 100644 --- a/BinaryObjectScanner.Test/FileType/CFBTests.cs +++ b/BinaryObjectScanner.Test/FileType/CFBTests.cs @@ -6,12 +6,15 @@ namespace BinaryObjectScanner.Test.FileType { public class CFBTests { + private static readonly SabreTools.Serialization.Wrappers.CFB wrapper + = new(new SabreTools.Models.CFB.Binary(), new MemoryStream()); + [Fact] public void ExtractFile_EmptyString_False() { string file = string.Empty; string outDir = string.Empty; - var extractable = new CFB(); + var extractable = new CFB(wrapper); bool actual = extractable.Extract(file, outDir, includeDebug: false); Assert.False(actual); @@ -23,7 +26,7 @@ namespace BinaryObjectScanner.Test.FileType Stream? stream = null; string file = string.Empty; string outDir = string.Empty; - var extractable = new CFB(); + var extractable = new CFB(wrapper); bool actual = extractable.Extract(stream, file, outDir, includeDebug: false); Assert.False(actual); @@ -35,7 +38,7 @@ namespace BinaryObjectScanner.Test.FileType Stream? stream = new MemoryStream(); string file = string.Empty; string outDir = string.Empty; - var extractable = new CFB(); + var extractable = new CFB(wrapper); bool actual = extractable.Extract(stream, file, outDir, includeDebug: false); Assert.False(actual); diff --git a/BinaryObjectScanner.Test/FileType/GCFTests.cs b/BinaryObjectScanner.Test/FileType/GCFTests.cs index ea9be85b..3f14f218 100644 --- a/BinaryObjectScanner.Test/FileType/GCFTests.cs +++ b/BinaryObjectScanner.Test/FileType/GCFTests.cs @@ -6,12 +6,15 @@ namespace BinaryObjectScanner.Test.FileType { public class GCFTests { + private static readonly SabreTools.Serialization.Wrappers.GCF wrapper + = new(new SabreTools.Models.GCF.File(), new MemoryStream()); + [Fact] public void ExtractFile_EmptyString_False() { string file = string.Empty; string outDir = string.Empty; - var extractable = new GCF(); + var extractable = new GCF(wrapper); bool actual = extractable.Extract(file, outDir, includeDebug: false); Assert.False(actual); @@ -23,7 +26,7 @@ namespace BinaryObjectScanner.Test.FileType Stream? stream = null; string file = string.Empty; string outDir = string.Empty; - var extractable = new GCF(); + var extractable = new GCF(wrapper); bool actual = extractable.Extract(stream, file, outDir, includeDebug: false); Assert.False(actual); @@ -35,7 +38,7 @@ namespace BinaryObjectScanner.Test.FileType Stream? stream = new MemoryStream(); string file = string.Empty; string outDir = string.Empty; - var extractable = new GCF(); + var extractable = new GCF(wrapper); bool actual = extractable.Extract(stream, file, outDir, includeDebug: false); Assert.False(actual); diff --git a/BinaryObjectScanner.Test/FileType/GZIPTests.cs b/BinaryObjectScanner.Test/FileType/GZIPTests.cs index 393b50e0..fab85f28 100644 --- a/BinaryObjectScanner.Test/FileType/GZIPTests.cs +++ b/BinaryObjectScanner.Test/FileType/GZIPTests.cs @@ -6,12 +6,15 @@ namespace BinaryObjectScanner.Test.FileType { public class GZIPTests { + private static readonly SabreTools.Serialization.Wrappers.GZip wrapper + = new(new SabreTools.Models.GZIP.Archive(), new MemoryStream()); + [Fact] public void ExtractFile_EmptyString_False() { string file = string.Empty; string outDir = string.Empty; - var extractable = new GZip(); + var extractable = new GZip(wrapper); bool actual = extractable.Extract(file, outDir, includeDebug: false); Assert.False(actual); @@ -23,7 +26,7 @@ namespace BinaryObjectScanner.Test.FileType Stream? stream = null; string file = string.Empty; string outDir = string.Empty; - var extractable = new GZip(); + var extractable = new GZip(wrapper); bool actual = extractable.Extract(stream, file, outDir, includeDebug: false); Assert.False(actual); @@ -35,7 +38,7 @@ namespace BinaryObjectScanner.Test.FileType Stream? stream = new MemoryStream(); string file = string.Empty; string outDir = string.Empty; - var extractable = new GZip(); + var extractable = new GZip(wrapper); bool actual = extractable.Extract(stream, file, outDir, includeDebug: false); Assert.False(actual); diff --git a/BinaryObjectScanner.Test/FileType/InstallShieldArchiveV3Tests.cs b/BinaryObjectScanner.Test/FileType/InstallShieldArchiveV3Tests.cs index 769ee998..5f076731 100644 --- a/BinaryObjectScanner.Test/FileType/InstallShieldArchiveV3Tests.cs +++ b/BinaryObjectScanner.Test/FileType/InstallShieldArchiveV3Tests.cs @@ -6,12 +6,15 @@ namespace BinaryObjectScanner.Test.FileType { public class InstallShieldArchiveV3Tests { + private static readonly SabreTools.Serialization.Wrappers.InstallShieldArchiveV3 wrapper + = new(new SabreTools.Models.InstallShieldArchiveV3.Archive(), new MemoryStream()); + [Fact] public void ExtractFile_EmptyString_False() { string file = string.Empty; string outDir = string.Empty; - var extractable = new InstallShieldArchiveV3(); + var extractable = new InstallShieldArchiveV3(wrapper); bool actual = extractable.Extract(file, outDir, includeDebug: false); Assert.False(actual); @@ -23,7 +26,7 @@ namespace BinaryObjectScanner.Test.FileType Stream? stream = null; string file = string.Empty; string outDir = string.Empty; - var extractable = new InstallShieldArchiveV3(); + var extractable = new InstallShieldArchiveV3(wrapper); bool actual = extractable.Extract(stream, file, outDir, includeDebug: false); Assert.False(actual); @@ -35,7 +38,7 @@ namespace BinaryObjectScanner.Test.FileType Stream? stream = new MemoryStream(); string file = string.Empty; string outDir = string.Empty; - var extractable = new InstallShieldArchiveV3(); + var extractable = new InstallShieldArchiveV3(wrapper); bool actual = extractable.Extract(stream, file, outDir, includeDebug: false); Assert.False(actual); diff --git a/BinaryObjectScanner.Test/FileType/InstallShieldCABTests.cs b/BinaryObjectScanner.Test/FileType/InstallShieldCABTests.cs index ff24b30d..a29f5a74 100644 --- a/BinaryObjectScanner.Test/FileType/InstallShieldCABTests.cs +++ b/BinaryObjectScanner.Test/FileType/InstallShieldCABTests.cs @@ -1,5 +1,4 @@ -using System; -using System.IO; +using System.IO; using BinaryObjectScanner.FileType; using Xunit; @@ -7,12 +6,15 @@ namespace BinaryObjectScanner.Test.FileType { public class InstallShieldCABTests { + private static readonly SabreTools.Serialization.Wrappers.InstallShieldCabinet wrapper + = new(new SabreTools.Models.InstallShieldCabinet.Cabinet(), new MemoryStream()); + [Fact] public void ExtractFile_EmptyString_False() { string file = string.Empty; string outDir = string.Empty; - var extractable = new InstallShieldCAB(); + var extractable = new InstallShieldCAB(wrapper); bool actual = extractable.Extract(file, outDir, includeDebug: false); Assert.False(actual); @@ -24,7 +26,7 @@ namespace BinaryObjectScanner.Test.FileType Stream? stream = null; string file = string.Empty; string outDir = string.Empty; - var extractable = new InstallShieldCAB(); + var extractable = new InstallShieldCAB(wrapper); bool actual = extractable.Extract(stream, file, outDir, includeDebug: false); Assert.False(actual); @@ -36,7 +38,7 @@ namespace BinaryObjectScanner.Test.FileType Stream? stream = new MemoryStream(); string file = string.Empty; string outDir = string.Empty; - var extractable = new InstallShieldCAB(); + var extractable = new InstallShieldCAB(wrapper); bool actual = extractable.Extract(stream, file, outDir, includeDebug: false); Assert.False(actual); diff --git a/BinaryObjectScanner.Test/FileType/LZKWAJTests.cs b/BinaryObjectScanner.Test/FileType/LZKWAJTests.cs index 2af4a437..9041f4ad 100644 --- a/BinaryObjectScanner.Test/FileType/LZKWAJTests.cs +++ b/BinaryObjectScanner.Test/FileType/LZKWAJTests.cs @@ -6,12 +6,15 @@ namespace BinaryObjectScanner.Test.FileType { public class LZKWAJTests { + private static readonly SabreTools.Serialization.Wrappers.LZKWAJ wrapper + = new(new SabreTools.Models.LZ.KWAJFile(), new MemoryStream()); + [Fact] public void ExtractFile_EmptyString_False() { string file = string.Empty; string outDir = string.Empty; - var extractable = new LZKWAJ(); + var extractable = new LZKWAJ(wrapper); bool actual = extractable.Extract(file, outDir, includeDebug: false); Assert.False(actual); @@ -23,7 +26,7 @@ namespace BinaryObjectScanner.Test.FileType Stream? stream = null; string file = string.Empty; string outDir = string.Empty; - var extractable = new LZKWAJ(); + var extractable = new LZKWAJ(wrapper); bool actual = extractable.Extract(stream, file, outDir, includeDebug: false); Assert.False(actual); @@ -35,7 +38,7 @@ namespace BinaryObjectScanner.Test.FileType Stream? stream = new MemoryStream(); string file = string.Empty; string outDir = string.Empty; - var extractable = new LZKWAJ(); + var extractable = new LZKWAJ(wrapper); bool actual = extractable.Extract(stream, file, outDir, includeDebug: false); Assert.False(actual); diff --git a/BinaryObjectScanner.Test/FileType/LZQBasicTests.cs b/BinaryObjectScanner.Test/FileType/LZQBasicTests.cs index 526a7cb9..1fe27f28 100644 --- a/BinaryObjectScanner.Test/FileType/LZQBasicTests.cs +++ b/BinaryObjectScanner.Test/FileType/LZQBasicTests.cs @@ -6,12 +6,15 @@ namespace BinaryObjectScanner.Test.FileType { public class LZQBasicTests { + private static readonly SabreTools.Serialization.Wrappers.LZQBasic wrapper + = new(new SabreTools.Models.LZ.QBasicFile(), new MemoryStream()); + [Fact] public void ExtractFile_EmptyString_False() { string file = string.Empty; string outDir = string.Empty; - var extractable = new LZQBasic(); + var extractable = new LZQBasic(wrapper); bool actual = extractable.Extract(file, outDir, includeDebug: false); Assert.False(actual); @@ -23,7 +26,7 @@ namespace BinaryObjectScanner.Test.FileType Stream? stream = null; string file = string.Empty; string outDir = string.Empty; - var extractable = new LZQBasic(); + var extractable = new LZQBasic(wrapper); bool actual = extractable.Extract(stream, file, outDir, includeDebug: false); Assert.False(actual); @@ -35,7 +38,7 @@ namespace BinaryObjectScanner.Test.FileType Stream? stream = new MemoryStream(); string file = string.Empty; string outDir = string.Empty; - var extractable = new LZQBasic(); + var extractable = new LZQBasic(wrapper); bool actual = extractable.Extract(stream, file, outDir, includeDebug: false); Assert.False(actual); diff --git a/BinaryObjectScanner.Test/FileType/LZSZDDTests.cs b/BinaryObjectScanner.Test/FileType/LZSZDDTests.cs index bbe689ec..ffbb7822 100644 --- a/BinaryObjectScanner.Test/FileType/LZSZDDTests.cs +++ b/BinaryObjectScanner.Test/FileType/LZSZDDTests.cs @@ -6,12 +6,15 @@ namespace BinaryObjectScanner.Test.FileType { public class LZSZDDTests { + private static readonly SabreTools.Serialization.Wrappers.LZSZDD wrapper + = new(new SabreTools.Models.LZ.SZDDFile(), new MemoryStream()); + [Fact] public void ExtractFile_EmptyString_False() { string file = string.Empty; string outDir = string.Empty; - var extractable = new LZSZDD(); + var extractable = new LZSZDD(wrapper); bool actual = extractable.Extract(file, outDir, includeDebug: false); Assert.False(actual); @@ -23,7 +26,7 @@ namespace BinaryObjectScanner.Test.FileType Stream? stream = null; string file = string.Empty; string outDir = string.Empty; - var extractable = new LZSZDD(); + var extractable = new LZSZDD(wrapper); bool actual = extractable.Extract(stream, file, outDir, includeDebug: false); Assert.False(actual); @@ -35,7 +38,7 @@ namespace BinaryObjectScanner.Test.FileType Stream? stream = new MemoryStream(); string file = string.Empty; string outDir = string.Empty; - var extractable = new LZSZDD(); + var extractable = new LZSZDD(wrapper); bool actual = extractable.Extract(stream, file, outDir, includeDebug: false); Assert.False(actual); diff --git a/BinaryObjectScanner.Test/FileType/MPQTests.cs b/BinaryObjectScanner.Test/FileType/MPQTests.cs index 6f2dd0d9..aa27e402 100644 --- a/BinaryObjectScanner.Test/FileType/MPQTests.cs +++ b/BinaryObjectScanner.Test/FileType/MPQTests.cs @@ -6,12 +6,15 @@ namespace BinaryObjectScanner.Test.FileType { public class MPQTests { + private static readonly SabreTools.Serialization.Wrappers.MoPaQ wrapper + = new(new SabreTools.Models.MoPaQ.Archive(), new MemoryStream()); + [Fact] public void ExtractFile_EmptyString_False() { string file = string.Empty; string outDir = string.Empty; - var extractable = new MPQ(); + var extractable = new MPQ(wrapper); bool actual = extractable.Extract(file, outDir, includeDebug: false); Assert.False(actual); @@ -23,7 +26,7 @@ namespace BinaryObjectScanner.Test.FileType Stream? stream = null; string file = string.Empty; string outDir = string.Empty; - var extractable = new MPQ(); + var extractable = new MPQ(wrapper); bool actual = extractable.Extract(stream, file, outDir, includeDebug: false); Assert.False(actual); @@ -35,7 +38,7 @@ namespace BinaryObjectScanner.Test.FileType Stream? stream = new MemoryStream(); string file = string.Empty; string outDir = string.Empty; - var extractable = new MPQ(); + var extractable = new MPQ(wrapper); bool actual = extractable.Extract(stream, file, outDir, includeDebug: false); Assert.False(actual); diff --git a/BinaryObjectScanner.Test/FileType/MicrosoftCABTests.cs b/BinaryObjectScanner.Test/FileType/MicrosoftCABTests.cs index 965d7c9c..fc3f10d8 100644 --- a/BinaryObjectScanner.Test/FileType/MicrosoftCABTests.cs +++ b/BinaryObjectScanner.Test/FileType/MicrosoftCABTests.cs @@ -6,12 +6,15 @@ namespace BinaryObjectScanner.Test.FileType { public class MicrosoftCABTests { + private static readonly SabreTools.Serialization.Wrappers.MicrosoftCabinet wrapper + = new(new SabreTools.Models.MicrosoftCabinet.Cabinet(), new MemoryStream()); + [Fact] public void ExtractFile_EmptyString_False() { string file = string.Empty; string outDir = string.Empty; - var extractable = new MicrosoftCAB(); + var extractable = new MicrosoftCAB(wrapper); bool actual = extractable.Extract(file, outDir, includeDebug: false); Assert.False(actual); @@ -23,7 +26,7 @@ namespace BinaryObjectScanner.Test.FileType Stream? stream = null; string file = string.Empty; string outDir = string.Empty; - var extractable = new MicrosoftCAB(); + var extractable = new MicrosoftCAB(wrapper); bool actual = extractable.Extract(stream, file, outDir, includeDebug: false); Assert.False(actual); @@ -35,7 +38,7 @@ namespace BinaryObjectScanner.Test.FileType Stream? stream = new MemoryStream(); string file = string.Empty; string outDir = string.Empty; - var extractable = new MicrosoftCAB(); + var extractable = new MicrosoftCAB(wrapper); bool actual = extractable.Extract(stream, file, outDir, includeDebug: false); Assert.False(actual); diff --git a/BinaryObjectScanner.Test/FileType/PAKTests.cs b/BinaryObjectScanner.Test/FileType/PAKTests.cs index fa02effa..0a010fb6 100644 --- a/BinaryObjectScanner.Test/FileType/PAKTests.cs +++ b/BinaryObjectScanner.Test/FileType/PAKTests.cs @@ -6,12 +6,15 @@ namespace BinaryObjectScanner.Test.FileType { public class PAKTests { + private static readonly SabreTools.Serialization.Wrappers.PAK wrapper + = new(new SabreTools.Models.PAK.File(), new MemoryStream()); + [Fact] public void ExtractFile_EmptyString_False() { string file = string.Empty; string outDir = string.Empty; - var extractable = new PAK(); + var extractable = new PAK(wrapper); bool actual = extractable.Extract(file, outDir, includeDebug: false); Assert.False(actual); @@ -23,7 +26,7 @@ namespace BinaryObjectScanner.Test.FileType Stream? stream = null; string file = string.Empty; string outDir = string.Empty; - var extractable = new PAK(); + var extractable = new PAK(wrapper); bool actual = extractable.Extract(stream, file, outDir, includeDebug: false); Assert.False(actual); @@ -35,7 +38,7 @@ namespace BinaryObjectScanner.Test.FileType Stream? stream = new MemoryStream(); string file = string.Empty; string outDir = string.Empty; - var extractable = new PAK(); + var extractable = new PAK(wrapper); bool actual = extractable.Extract(stream, file, outDir, includeDebug: false); Assert.False(actual); diff --git a/BinaryObjectScanner.Test/FileType/PFFTests.cs b/BinaryObjectScanner.Test/FileType/PFFTests.cs index 408a20fb..8a97a156 100644 --- a/BinaryObjectScanner.Test/FileType/PFFTests.cs +++ b/BinaryObjectScanner.Test/FileType/PFFTests.cs @@ -6,12 +6,15 @@ namespace BinaryObjectScanner.Test.FileType { public class PFFTests { + private static readonly SabreTools.Serialization.Wrappers.PFF wrapper + = new(new SabreTools.Models.PFF.Archive(), new MemoryStream()); + [Fact] public void ExtractFile_EmptyString_False() { string file = string.Empty; string outDir = string.Empty; - var extractable = new PFF(); + var extractable = new PFF(wrapper); bool actual = extractable.Extract(file, outDir, includeDebug: false); Assert.False(actual); @@ -23,7 +26,7 @@ namespace BinaryObjectScanner.Test.FileType Stream? stream = null; string file = string.Empty; string outDir = string.Empty; - var extractable = new PFF(); + var extractable = new PFF(wrapper); bool actual = extractable.Extract(stream, file, outDir, includeDebug: false); Assert.False(actual); @@ -35,7 +38,7 @@ namespace BinaryObjectScanner.Test.FileType Stream? stream = new MemoryStream(); string file = string.Empty; string outDir = string.Empty; - var extractable = new PFF(); + var extractable = new PFF(wrapper); bool actual = extractable.Extract(stream, file, outDir, includeDebug: false); Assert.False(actual); diff --git a/BinaryObjectScanner.Test/FileType/PKZIPTests.cs b/BinaryObjectScanner.Test/FileType/PKZIPTests.cs index 4699ef23..f38040fd 100644 --- a/BinaryObjectScanner.Test/FileType/PKZIPTests.cs +++ b/BinaryObjectScanner.Test/FileType/PKZIPTests.cs @@ -6,12 +6,15 @@ namespace BinaryObjectScanner.Test.FileType { public class PKZIPTests { + private static readonly SabreTools.Serialization.Wrappers.PKZIP wrapper + = new(new SabreTools.Models.PKZIP.Archive(), new MemoryStream()); + [Fact] public void ExtractFile_EmptyString_False() { string file = string.Empty; string outDir = string.Empty; - var extractable = new PKZIP(); + var extractable = new PKZIP(wrapper); bool actual = extractable.Extract(file, outDir, includeDebug: false); Assert.False(actual); @@ -23,7 +26,7 @@ namespace BinaryObjectScanner.Test.FileType Stream? stream = null; string file = string.Empty; string outDir = string.Empty; - var extractable = new PKZIP(); + var extractable = new PKZIP(wrapper); bool actual = extractable.Extract(stream, file, outDir, includeDebug: false); Assert.False(actual); @@ -35,7 +38,7 @@ namespace BinaryObjectScanner.Test.FileType Stream? stream = new MemoryStream(); string file = string.Empty; string outDir = string.Empty; - var extractable = new PKZIP(); + var extractable = new PKZIP(wrapper); bool actual = extractable.Extract(stream, file, outDir, includeDebug: false); Assert.False(actual); diff --git a/BinaryObjectScanner.Test/FileType/QuantumTests.cs b/BinaryObjectScanner.Test/FileType/QuantumTests.cs index 9e7d0d2a..4ddfcb20 100644 --- a/BinaryObjectScanner.Test/FileType/QuantumTests.cs +++ b/BinaryObjectScanner.Test/FileType/QuantumTests.cs @@ -6,12 +6,15 @@ namespace BinaryObjectScanner.Test.FileType { public class QuantumTests { + private static readonly SabreTools.Serialization.Wrappers.Quantum wrapper + = new(new SabreTools.Models.Quantum.Archive(), new MemoryStream()); + [Fact] public void ExtractFile_EmptyString_False() { string file = string.Empty; string outDir = string.Empty; - var extractable = new Quantum(); + var extractable = new Quantum(wrapper); bool actual = extractable.Extract(file, outDir, includeDebug: false); Assert.False(actual); @@ -23,7 +26,7 @@ namespace BinaryObjectScanner.Test.FileType Stream? stream = null; string file = string.Empty; string outDir = string.Empty; - var extractable = new Quantum(); + var extractable = new Quantum(wrapper); bool actual = extractable.Extract(stream, file, outDir, includeDebug: false); Assert.False(actual); @@ -35,7 +38,7 @@ namespace BinaryObjectScanner.Test.FileType Stream? stream = new MemoryStream(); string file = string.Empty; string outDir = string.Empty; - var extractable = new Quantum(); + var extractable = new Quantum(wrapper); bool actual = extractable.Extract(stream, file, outDir, includeDebug: false); Assert.False(actual); diff --git a/BinaryObjectScanner.Test/FileType/RARTests.cs b/BinaryObjectScanner.Test/FileType/RARTests.cs index 6c94e7ae..aa5b865b 100644 --- a/BinaryObjectScanner.Test/FileType/RARTests.cs +++ b/BinaryObjectScanner.Test/FileType/RARTests.cs @@ -6,12 +6,15 @@ namespace BinaryObjectScanner.Test.FileType { public class RARTests { + private static readonly SabreTools.Serialization.Wrappers.RAR wrapper + = new(new MemoryStream()); + [Fact] public void ExtractFile_EmptyString_False() { string file = string.Empty; string outDir = string.Empty; - var extractable = new RAR(); + var extractable = new RAR(wrapper); bool actual = extractable.Extract(file, outDir, includeDebug: false); Assert.False(actual); @@ -23,7 +26,7 @@ namespace BinaryObjectScanner.Test.FileType Stream? stream = null; string file = string.Empty; string outDir = string.Empty; - var extractable = new RAR(); + var extractable = new RAR(wrapper); bool actual = extractable.Extract(stream, file, outDir, includeDebug: false); Assert.False(actual); @@ -35,7 +38,7 @@ namespace BinaryObjectScanner.Test.FileType Stream? stream = new MemoryStream(); string file = string.Empty; string outDir = string.Empty; - var extractable = new RAR(); + var extractable = new RAR(wrapper); bool actual = extractable.Extract(stream, file, outDir, includeDebug: false); Assert.False(actual); diff --git a/BinaryObjectScanner.Test/FileType/SGATests.cs b/BinaryObjectScanner.Test/FileType/SGATests.cs index 6039c562..2bbf7ebb 100644 --- a/BinaryObjectScanner.Test/FileType/SGATests.cs +++ b/BinaryObjectScanner.Test/FileType/SGATests.cs @@ -6,12 +6,15 @@ namespace BinaryObjectScanner.Test.FileType { public class SGATests { + private static readonly SabreTools.Serialization.Wrappers.SGA wrapper + = new(new SabreTools.Models.SGA.Archive(), new MemoryStream()); + [Fact] public void ExtractFile_EmptyString_False() { string file = string.Empty; string outDir = string.Empty; - var extractable = new SGA(); + var extractable = new SGA(wrapper); bool actual = extractable.Extract(file, outDir, includeDebug: false); Assert.False(actual); @@ -23,7 +26,7 @@ namespace BinaryObjectScanner.Test.FileType Stream? stream = null; string file = string.Empty; string outDir = string.Empty; - var extractable = new SGA(); + var extractable = new SGA(wrapper); bool actual = extractable.Extract(stream, file, outDir, includeDebug: false); Assert.False(actual); @@ -35,7 +38,7 @@ namespace BinaryObjectScanner.Test.FileType Stream? stream = new MemoryStream(); string file = string.Empty; string outDir = string.Empty; - var extractable = new SGA(); + var extractable = new SGA(wrapper); bool actual = extractable.Extract(stream, file, outDir, includeDebug: false); Assert.False(actual); diff --git a/BinaryObjectScanner.Test/FileType/SevenZipTests.cs b/BinaryObjectScanner.Test/FileType/SevenZipTests.cs index 4b7692db..98d7708d 100644 --- a/BinaryObjectScanner.Test/FileType/SevenZipTests.cs +++ b/BinaryObjectScanner.Test/FileType/SevenZipTests.cs @@ -6,12 +6,15 @@ namespace BinaryObjectScanner.Test.FileType { public class SevenZipTests { + private static readonly SabreTools.Serialization.Wrappers.SevenZip wrapper + = new(new MemoryStream()); + [Fact] public void ExtractFile_EmptyString_False() { string file = string.Empty; string outDir = string.Empty; - var extractable = new SevenZip(); + var extractable = new SevenZip(wrapper); bool actual = extractable.Extract(file, outDir, includeDebug: false); Assert.False(actual); @@ -23,7 +26,7 @@ namespace BinaryObjectScanner.Test.FileType Stream? stream = null; string file = string.Empty; string outDir = string.Empty; - var extractable = new SevenZip(); + var extractable = new SevenZip(wrapper); bool actual = extractable.Extract(stream, file, outDir, includeDebug: false); Assert.False(actual); @@ -35,7 +38,7 @@ namespace BinaryObjectScanner.Test.FileType Stream? stream = new MemoryStream(); string file = string.Empty; string outDir = string.Empty; - var extractable = new SevenZip(); + var extractable = new SevenZip(wrapper); bool actual = extractable.Extract(stream, file, outDir, includeDebug: false); Assert.False(actual); diff --git a/BinaryObjectScanner.Test/FileType/TapeArchiveTests.cs b/BinaryObjectScanner.Test/FileType/TapeArchiveTests.cs index 4cab953a..09103620 100644 --- a/BinaryObjectScanner.Test/FileType/TapeArchiveTests.cs +++ b/BinaryObjectScanner.Test/FileType/TapeArchiveTests.cs @@ -6,12 +6,15 @@ namespace BinaryObjectScanner.Test.FileType { public class TapeArchiveTests { + private static readonly SabreTools.Serialization.Wrappers.TapeArchive wrapper + = new(new SabreTools.Models.TAR.Archive(), new MemoryStream()); + [Fact] public void ExtractFile_EmptyString_False() { string file = string.Empty; string outDir = string.Empty; - var extractable = new TapeArchive(); + var extractable = new TapeArchive(wrapper); bool actual = extractable.Extract(file, outDir, includeDebug: false); Assert.False(actual); @@ -23,7 +26,7 @@ namespace BinaryObjectScanner.Test.FileType Stream? stream = null; string file = string.Empty; string outDir = string.Empty; - var extractable = new TapeArchive(); + var extractable = new TapeArchive(wrapper); bool actual = extractable.Extract(stream, file, outDir, includeDebug: false); Assert.False(actual); @@ -35,7 +38,7 @@ namespace BinaryObjectScanner.Test.FileType Stream? stream = new MemoryStream(); string file = string.Empty; string outDir = string.Empty; - var extractable = new TapeArchive(); + var extractable = new TapeArchive(wrapper); bool actual = extractable.Extract(stream, file, outDir, includeDebug: false); Assert.False(actual); diff --git a/BinaryObjectScanner.Test/FileType/VBSPTests.cs b/BinaryObjectScanner.Test/FileType/VBSPTests.cs index ef7bba00..8f25d552 100644 --- a/BinaryObjectScanner.Test/FileType/VBSPTests.cs +++ b/BinaryObjectScanner.Test/FileType/VBSPTests.cs @@ -6,12 +6,15 @@ namespace BinaryObjectScanner.Test.FileType { public class VBSPTests { + private static readonly SabreTools.Serialization.Wrappers.VBSP wrapper + = new(new SabreTools.Models.BSP.VbspFile(), new MemoryStream()); + [Fact] public void ExtractFile_EmptyString_False() { string file = string.Empty; string outDir = string.Empty; - var extractable = new VBSP(); + var extractable = new VBSP(wrapper); bool actual = extractable.Extract(file, outDir, includeDebug: false); Assert.False(actual); @@ -23,7 +26,7 @@ namespace BinaryObjectScanner.Test.FileType Stream? stream = null; string file = string.Empty; string outDir = string.Empty; - var extractable = new VBSP(); + var extractable = new VBSP(wrapper); bool actual = extractable.Extract(stream, file, outDir, includeDebug: false); Assert.False(actual); @@ -35,7 +38,7 @@ namespace BinaryObjectScanner.Test.FileType Stream? stream = new MemoryStream(); string file = string.Empty; string outDir = string.Empty; - var extractable = new VBSP(); + var extractable = new VBSP(wrapper); bool actual = extractable.Extract(stream, file, outDir, includeDebug: false); Assert.False(actual); diff --git a/BinaryObjectScanner.Test/FileType/VPKTests.cs b/BinaryObjectScanner.Test/FileType/VPKTests.cs index a797bfec..1f9a2e17 100644 --- a/BinaryObjectScanner.Test/FileType/VPKTests.cs +++ b/BinaryObjectScanner.Test/FileType/VPKTests.cs @@ -6,12 +6,15 @@ namespace BinaryObjectScanner.Test.FileType { public class VPKTests { + private static readonly SabreTools.Serialization.Wrappers.VPK wrapper + = new(new SabreTools.Models.VPK.File(), new MemoryStream()); + [Fact] public void ExtractFile_EmptyString_False() { string file = string.Empty; string outDir = string.Empty; - var extractable = new VPK(); + var extractable = new VPK(wrapper); bool actual = extractable.Extract(file, outDir, includeDebug: false); Assert.False(actual); @@ -23,7 +26,7 @@ namespace BinaryObjectScanner.Test.FileType Stream? stream = null; string file = string.Empty; string outDir = string.Empty; - var extractable = new VPK(); + var extractable = new VPK(wrapper); bool actual = extractable.Extract(stream, file, outDir, includeDebug: false); Assert.False(actual); @@ -35,7 +38,7 @@ namespace BinaryObjectScanner.Test.FileType Stream? stream = new MemoryStream(); string file = string.Empty; string outDir = string.Empty; - var extractable = new VPK(); + var extractable = new VPK(wrapper); bool actual = extractable.Extract(stream, file, outDir, includeDebug: false); Assert.False(actual); diff --git a/BinaryObjectScanner.Test/FileType/WAD3Tests.cs b/BinaryObjectScanner.Test/FileType/WAD3Tests.cs index de5b1147..3c528687 100644 --- a/BinaryObjectScanner.Test/FileType/WAD3Tests.cs +++ b/BinaryObjectScanner.Test/FileType/WAD3Tests.cs @@ -6,12 +6,15 @@ namespace BinaryObjectScanner.Test.FileType { public class WAD3Tests { + private static readonly SabreTools.Serialization.Wrappers.WAD3 wrapper + = new(new SabreTools.Models.WAD3.File(), new MemoryStream()); + [Fact] public void ExtractFile_EmptyString_False() { string file = string.Empty; string outDir = string.Empty; - var extractable = new WAD3(); + var extractable = new WAD3(wrapper); bool actual = extractable.Extract(file, outDir, includeDebug: false); Assert.False(actual); @@ -23,7 +26,7 @@ namespace BinaryObjectScanner.Test.FileType Stream? stream = null; string file = string.Empty; string outDir = string.Empty; - var extractable = new WAD3(); + var extractable = new WAD3(wrapper); bool actual = extractable.Extract(stream, file, outDir, includeDebug: false); Assert.False(actual); @@ -35,7 +38,7 @@ namespace BinaryObjectScanner.Test.FileType Stream? stream = new MemoryStream(); string file = string.Empty; string outDir = string.Empty; - var extractable = new WAD3(); + var extractable = new WAD3(wrapper); bool actual = extractable.Extract(stream, file, outDir, includeDebug: false); Assert.False(actual); diff --git a/BinaryObjectScanner.Test/FileType/XZPTests.cs b/BinaryObjectScanner.Test/FileType/XZPTests.cs index ec36029d..42c40ac8 100644 --- a/BinaryObjectScanner.Test/FileType/XZPTests.cs +++ b/BinaryObjectScanner.Test/FileType/XZPTests.cs @@ -6,12 +6,15 @@ namespace BinaryObjectScanner.Test.FileType { public class XZPTests { + private static readonly SabreTools.Serialization.Wrappers.XZP wrapper + = new(new SabreTools.Models.XZP.File(), new MemoryStream()); + [Fact] public void ExtractFile_EmptyString_False() { string file = string.Empty; string outDir = string.Empty; - var extractable = new XZP(); + var extractable = new XZP(wrapper); bool actual = extractable.Extract(file, outDir, includeDebug: false); Assert.False(actual); @@ -23,7 +26,7 @@ namespace BinaryObjectScanner.Test.FileType Stream? stream = null; string file = string.Empty; string outDir = string.Empty; - var extractable = new XZP(); + var extractable = new XZP(wrapper); bool actual = extractable.Extract(stream, file, outDir, includeDebug: false); Assert.False(actual); @@ -35,7 +38,7 @@ namespace BinaryObjectScanner.Test.FileType Stream? stream = new MemoryStream(); string file = string.Empty; string outDir = string.Empty; - var extractable = new XZP(); + var extractable = new XZP(wrapper); bool actual = extractable.Extract(stream, file, outDir, includeDebug: false); Assert.False(actual); diff --git a/BinaryObjectScanner.Test/FileType/XZTests.cs b/BinaryObjectScanner.Test/FileType/XZTests.cs index de083c08..a5e39715 100644 --- a/BinaryObjectScanner.Test/FileType/XZTests.cs +++ b/BinaryObjectScanner.Test/FileType/XZTests.cs @@ -6,12 +6,15 @@ namespace BinaryObjectScanner.Test.FileType { public class XZTests { + private static readonly SabreTools.Serialization.Wrappers.XZ wrapper + = new(new MemoryStream()); + [Fact] public void ExtractFile_EmptyString_False() { string file = string.Empty; string outDir = string.Empty; - var extractable = new XZ(); + var extractable = new XZ(wrapper); bool actual = extractable.Extract(file, outDir, includeDebug: false); Assert.False(actual); @@ -23,7 +26,7 @@ namespace BinaryObjectScanner.Test.FileType Stream? stream = null; string file = string.Empty; string outDir = string.Empty; - var extractable = new XZ(); + var extractable = new XZ(wrapper); bool actual = extractable.Extract(stream, file, outDir, includeDebug: false); Assert.False(actual); @@ -35,7 +38,7 @@ namespace BinaryObjectScanner.Test.FileType Stream? stream = new MemoryStream(); string file = string.Empty; string outDir = string.Empty; - var extractable = new XZ(); + var extractable = new XZ(wrapper); bool actual = extractable.Extract(stream, file, outDir, includeDebug: false); Assert.False(actual); diff --git a/BinaryObjectScanner/Factory.cs b/BinaryObjectScanner/Factory.cs index adec5183..451d5cb2 100644 --- a/BinaryObjectScanner/Factory.cs +++ b/BinaryObjectScanner/Factory.cs @@ -58,81 +58,50 @@ namespace BinaryObjectScanner // Use the wrapper before the type switch (wrapper) { - case BFPK: return new FileType.BFPK(); - case BSP: return new FileType.BSP(); - case BZip2: return new FileType.BZip2(); - case CFB: return new FileType.CFB(); + case BFPK obj: return new FileType.BFPK(obj); + case BSP obj: return new FileType.BSP(obj); + case BZip2 obj: return new FileType.BZip2(obj); + case CFB obj: return new FileType.CFB(obj); // case CIA => new FileType.CIA(), - case GCF: return new FileType.GCF(); - case GZip: return new FileType.GZip(); - case InstallShieldArchiveV3: return new FileType.InstallShieldArchiveV3(); - case InstallShieldCabinet: return new FileType.InstallShieldCAB(); - case LZKWAJ: return new FileType.LZKWAJ(); - case LZQBasic: return new FileType.LZQBasic(); - case LZSZDD: return new FileType.LZSZDD(); - case MicrosoftCabinet: return new FileType.MicrosoftCAB(); - case MoPaQ: return new FileType.MPQ(); + case GCF obj: return new FileType.GCF(obj); + case GZip obj: return new FileType.GZip(obj); + case InstallShieldArchiveV3 obj: return new FileType.InstallShieldArchiveV3(obj); + case InstallShieldCabinet obj: return new FileType.InstallShieldCAB(obj); + case LZKWAJ obj: return new FileType.LZKWAJ(obj); + case LZQBasic obj: return new FileType.LZQBasic(obj); + case LZSZDD obj: return new FileType.LZSZDD(obj); + case MicrosoftCabinet obj: return new FileType.MicrosoftCAB(obj); + case MoPaQ obj: return new FileType.MPQ(obj); // case N3DS: return new FileType.N3DS(); // case NCF: return new FileType.NCF(); case NewExecutable obj: return new FileType.NewExecutable(obj); // case Nitro: return new FileType.Nitro(); - case PAK: return new FileType.PAK(); - case PFF: return new FileType.PFF(); - case PKZIP: return new FileType.PKZIP(); + case PAK obj: return new FileType.PAK(obj); + case PFF obj: return new FileType.PFF(obj); + case PKZIP obj: return new FileType.PKZIP(obj); // case PlayJAudioFile: return new FileType.PLJ(); case PortableExecutable obj: return new FileType.PortableExecutable(obj); - case Quantum: return new FileType.Quantum(); - case RAR: return new FileType.RAR(); - case SevenZip: return new FileType.SevenZip(); - case SGA: return new FileType.SGA(); - case TapeArchive: return new FileType.TapeArchive(); - case VBSP: return new FileType.VBSP(); - case VPK: return new FileType.VPK(); - case WAD3: return new FileType.WAD3(); - case XZ: return new FileType.XZ(); - case XZP: return new FileType.XZP(); + case Quantum obj: return new FileType.Quantum(obj); + case RAR obj: return new FileType.RAR(obj); + case SevenZip obj: return new FileType.SevenZip(obj); + case SGA obj: return new FileType.SGA(obj); + case TapeArchive obj: return new FileType.TapeArchive(obj); + case VBSP obj: return new FileType.VBSP(obj); + case VPK obj: return new FileType.VPK(obj); + case WAD3 obj: return new FileType.WAD3(obj); + case XZ obj: return new FileType.XZ(obj); + case XZP obj: return new FileType.XZP(obj); } // Fall back on the file type for types not implemented in Serialization return fileType switch { - WrapperType.BFPK => new FileType.BFPK(), - WrapperType.BSP => new FileType.BSP(), - WrapperType.BZip2 => new FileType.BZip2(), - WrapperType.CFB => new FileType.CFB(), // WrapperType.CIA => new FileType.CIA(), - // WrapperType.Executable => new FileType.Executable(), - WrapperType.GCF => new FileType.GCF(), - WrapperType.GZip => new FileType.GZip(), - WrapperType.InstallShieldArchiveV3 => new FileType.InstallShieldArchiveV3(), - WrapperType.InstallShieldCAB => new FileType.InstallShieldCAB(), - // WrapperType.LinearExecutable => new FileType.LinearExecutable(), - WrapperType.LZKWAJ => new FileType.LZKWAJ(), - WrapperType.LZQBasic => new FileType.LZQBasic(), - WrapperType.LZSZDD => new FileType.LZSZDD(), - WrapperType.MicrosoftCAB => new FileType.MicrosoftCAB(), - WrapperType.MoPaQ => new FileType.MPQ(), - // WrapperType.MSDOS => new FileType.MSDOS(), // WrapperType.N3DS => new FileType.N3DS(), // WrapperType.NCF => new FileType.NCF(), - // WrapperType.NewExecutable => new FileType.NewExecutable(), // WrapperType.Nitro => new FileType.Nitro(), - WrapperType.PAK => new FileType.PAK(), - WrapperType.PFF => new FileType.PFF(), - WrapperType.PKZIP => new FileType.PKZIP(), // WrapperType.PlayJAudioFile => new FileType.PLJ(), - // WrapperType.PortableExecutable => new FileType.PortableExecutable(), - // WrapperType.Quantum => new FileType.Quantum(), - WrapperType.RAR => new FileType.RAR(), - WrapperType.SevenZip => new FileType.SevenZip(), WrapperType.SFFS => new FileType.SFFS(), - WrapperType.SGA => new FileType.SGA(), - WrapperType.TapeArchive => new FileType.TapeArchive(), - WrapperType.VBSP => new FileType.VBSP(), - WrapperType.VPK => new FileType.VPK(), - WrapperType.WAD => new FileType.WAD3(), - WrapperType.XZ => new FileType.XZ(), - WrapperType.XZP => new FileType.XZP(), _ => null, }; } diff --git a/BinaryObjectScanner/FileType/BFPK.cs b/BinaryObjectScanner/FileType/BFPK.cs index 372bf2a4..70fc4b04 100644 --- a/BinaryObjectScanner/FileType/BFPK.cs +++ b/BinaryObjectScanner/FileType/BFPK.cs @@ -1,25 +1,17 @@ using System.IO; -using BinaryObjectScanner.Interfaces; namespace BinaryObjectScanner.FileType { /// /// BFPK custom archive format /// - public class BFPK : IExtractable + public class BFPK : ExtractableBase { /// - 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 BFPK(SabreTools.Serialization.Wrappers.BFPK? wrapper) : base(wrapper) { } /// - 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 wrapper var bfpk = SabreTools.Serialization.Wrappers.BFPK.Create(stream); diff --git a/BinaryObjectScanner/FileType/BSP.cs b/BinaryObjectScanner/FileType/BSP.cs index b0d47cfc..07d2344f 100644 --- a/BinaryObjectScanner/FileType/BSP.cs +++ b/BinaryObjectScanner/FileType/BSP.cs @@ -1,25 +1,17 @@ using System.IO; -using BinaryObjectScanner.Interfaces; namespace BinaryObjectScanner.FileType { /// /// Half-Life Level /// - public class BSP : IExtractable + public class BSP : ExtractableBase { /// - 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 BSP(SabreTools.Serialization.Wrappers.BSP? wrapper) : base(wrapper) { } /// - 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 wrapper var bsp = SabreTools.Serialization.Wrappers.BSP.Create(stream); diff --git a/BinaryObjectScanner/FileType/BZip2.cs b/BinaryObjectScanner/FileType/BZip2.cs index be431739..23c6ee9f 100644 --- a/BinaryObjectScanner/FileType/BZip2.cs +++ b/BinaryObjectScanner/FileType/BZip2.cs @@ -1,25 +1,17 @@ using System.IO; -using BinaryObjectScanner.Interfaces; namespace BinaryObjectScanner.FileType { /// /// bzip2 archive /// - public class BZip2 : IExtractable + public class BZip2 : ExtractableBase { /// - 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 BZip2(SabreTools.Serialization.Wrappers.BZip2? wrapper) : base(wrapper) { } /// - public bool Extract(Stream? stream, string file, string outDir, bool includeDebug) + public override bool Extract(Stream? stream, string file, string outDir, bool includeDebug) { // Handle invalid inputs if (stream == null || stream.Length == 0) diff --git a/BinaryObjectScanner/FileType/CFB.cs b/BinaryObjectScanner/FileType/CFB.cs index b1c1b44d..39f84154 100644 --- a/BinaryObjectScanner/FileType/CFB.cs +++ b/BinaryObjectScanner/FileType/CFB.cs @@ -1,25 +1,17 @@ using System.IO; -using BinaryObjectScanner.Interfaces; namespace BinaryObjectScanner.FileType { /// /// Compound File Binary /// - public class CFB : IExtractable + public class CFB : ExtractableBase { /// - 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 CFB(SabreTools.Serialization.Wrappers.CFB? wrapper) : base(wrapper) { } /// - 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 wrapper var cfb = SabreTools.Serialization.Wrappers.CFB.Create(stream); diff --git a/BinaryObjectScanner/FileType/ExtractableBase.cs b/BinaryObjectScanner/FileType/ExtractableBase.cs new file mode 100644 index 00000000..02d5d403 --- /dev/null +++ b/BinaryObjectScanner/FileType/ExtractableBase.cs @@ -0,0 +1,34 @@ +using System.IO; +using BinaryObjectScanner.Interfaces; + +namespace BinaryObjectScanner.FileType +{ + /// + /// Base class for all standard extractable types + /// + public abstract class ExtractableBase : IExtractable + { + #region Constructors + + public ExtractableBase() { } + + #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/ExtractableBaseT.cs b/BinaryObjectScanner/FileType/ExtractableBaseT.cs new file mode 100644 index 00000000..3012e85c --- /dev/null +++ b/BinaryObjectScanner/FileType/ExtractableBaseT.cs @@ -0,0 +1,33 @@ +using System; +using BinaryObjectScanner.Interfaces; +using SabreTools.Serialization.Interfaces; + +namespace BinaryObjectScanner.FileType +{ + /// + /// Base class for all standard extractable types with a wrapper + /// + public abstract class ExtractableBase : ExtractableBase, IExtractable where T : IWrapper + { + #region Protected Instance Variables + + /// + /// Wrapper representing the extractable + /// + protected T _wrapper { get; private set; } + + #endregion + + #region Constructors + + public ExtractableBase(T? wrapper) + { + if (wrapper == null) + throw new ArgumentNullException(nameof(wrapper)); + + _wrapper = wrapper; + } + + #endregion + } +} \ No newline at end of file diff --git a/BinaryObjectScanner/FileType/GCF.cs b/BinaryObjectScanner/FileType/GCF.cs index cf9bcfd7..689750f1 100644 --- a/BinaryObjectScanner/FileType/GCF.cs +++ b/BinaryObjectScanner/FileType/GCF.cs @@ -1,25 +1,17 @@ using System.IO; -using BinaryObjectScanner.Interfaces; namespace BinaryObjectScanner.FileType { /// /// Half-Life Game Cache File /// - public class GCF : IExtractable + public class GCF : ExtractableBase { /// - 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 GCF(SabreTools.Serialization.Wrappers.GCF? wrapper) : base(wrapper) { } /// - 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 wrapper var gcf = SabreTools.Serialization.Wrappers.GCF.Create(stream); diff --git a/BinaryObjectScanner/FileType/GZip.cs b/BinaryObjectScanner/FileType/GZip.cs index 00041524..a0d61592 100644 --- a/BinaryObjectScanner/FileType/GZip.cs +++ b/BinaryObjectScanner/FileType/GZip.cs @@ -1,25 +1,17 @@ using System.IO; -using BinaryObjectScanner.Interfaces; namespace BinaryObjectScanner.FileType { /// /// gzip archive /// - public class GZip : IExtractable + public class GZip : ExtractableBase { /// - 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 GZip(SabreTools.Serialization.Wrappers.GZip? wrapper) : base(wrapper) { } /// - 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 wrapper var gcf = SabreTools.Serialization.Wrappers.GZip.Create(stream); diff --git a/BinaryObjectScanner/FileType/InstallShieldArchiveV3.cs b/BinaryObjectScanner/FileType/InstallShieldArchiveV3.cs index 95db39b2..ded3763b 100644 --- a/BinaryObjectScanner/FileType/InstallShieldArchiveV3.cs +++ b/BinaryObjectScanner/FileType/InstallShieldArchiveV3.cs @@ -1,25 +1,17 @@ using System.IO; -using BinaryObjectScanner.Interfaces; namespace BinaryObjectScanner.FileType { /// /// InstallShield archive v3 /// - public class InstallShieldArchiveV3 : IExtractable + public class InstallShieldArchiveV3 : ExtractableBase { /// - 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 InstallShieldArchiveV3(SabreTools.Serialization.Wrappers.InstallShieldArchiveV3? wrapper) : base(wrapper) { } /// - 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 wrapper var isv3 = SabreTools.Serialization.Wrappers.InstallShieldArchiveV3.Create(stream); diff --git a/BinaryObjectScanner/FileType/InstallShieldCAB.cs b/BinaryObjectScanner/FileType/InstallShieldCAB.cs index 072c8732..1ed38d64 100644 --- a/BinaryObjectScanner/FileType/InstallShieldCAB.cs +++ b/BinaryObjectScanner/FileType/InstallShieldCAB.cs @@ -1,25 +1,17 @@ using System.IO; -using BinaryObjectScanner.Interfaces; namespace BinaryObjectScanner.FileType { /// /// InstallShield cabinet file /// - public class InstallShieldCAB : IExtractable + public class InstallShieldCAB : ExtractableBase { /// - 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 InstallShieldCAB(SabreTools.Serialization.Wrappers.InstallShieldCabinet? wrapper) : base(wrapper) { } /// - 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 wrapper var iscab = SabreTools.Serialization.Wrappers.InstallShieldCabinet.Create(stream); diff --git a/BinaryObjectScanner/FileType/LZKWAJ.cs b/BinaryObjectScanner/FileType/LZKWAJ.cs index f8398c13..2f90b0cb 100644 --- a/BinaryObjectScanner/FileType/LZKWAJ.cs +++ b/BinaryObjectScanner/FileType/LZKWAJ.cs @@ -1,25 +1,17 @@ using System.IO; -using BinaryObjectScanner.Interfaces; namespace BinaryObjectScanner.FileType { /// /// LZ-compressed file, KWAJ variant /// - public class LZKWAJ : IExtractable + public class LZKWAJ : ExtractableBase { /// - 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 LZKWAJ(SabreTools.Serialization.Wrappers.LZKWAJ? wrapper) : base(wrapper) { } /// - 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 wrapper var kwaj = SabreTools.Serialization.Wrappers.LZKWAJ.Create(stream); diff --git a/BinaryObjectScanner/FileType/LZQBasic.cs b/BinaryObjectScanner/FileType/LZQBasic.cs index b749edf0..1dc8eed8 100644 --- a/BinaryObjectScanner/FileType/LZQBasic.cs +++ b/BinaryObjectScanner/FileType/LZQBasic.cs @@ -1,25 +1,17 @@ using System.IO; -using BinaryObjectScanner.Interfaces; namespace BinaryObjectScanner.FileType { /// /// LZ-compressed file, QBasic variant /// - public class LZQBasic : IExtractable + public class LZQBasic : ExtractableBase { /// - 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 LZQBasic(SabreTools.Serialization.Wrappers.LZQBasic? wrapper) : base(wrapper) { } /// - 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 wrapper var qbasic = SabreTools.Serialization.Wrappers.LZQBasic.Create(stream); diff --git a/BinaryObjectScanner/FileType/LZSZDD.cs b/BinaryObjectScanner/FileType/LZSZDD.cs index 70fd39cb..3e3f3066 100644 --- a/BinaryObjectScanner/FileType/LZSZDD.cs +++ b/BinaryObjectScanner/FileType/LZSZDD.cs @@ -1,25 +1,17 @@ using System.IO; -using BinaryObjectScanner.Interfaces; namespace BinaryObjectScanner.FileType { /// /// LZ-compressed file, SZDD variant /// - public class LZSZDD : IExtractable + public class LZSZDD : ExtractableBase { /// - 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 LZSZDD(SabreTools.Serialization.Wrappers.LZSZDD? wrapper) : base(wrapper) { } /// - 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 wrapper var szdd = SabreTools.Serialization.Wrappers.LZSZDD.Create(stream); diff --git a/BinaryObjectScanner/FileType/MPQ.cs b/BinaryObjectScanner/FileType/MPQ.cs index 48c860a4..a71fd72d 100644 --- a/BinaryObjectScanner/FileType/MPQ.cs +++ b/BinaryObjectScanner/FileType/MPQ.cs @@ -1,25 +1,17 @@ using System.IO; -using BinaryObjectScanner.Interfaces; namespace BinaryObjectScanner.FileType { /// /// MoPaQ game data archive /// - public class MPQ : IExtractable + public class MPQ : ExtractableBase { /// - 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 MPQ(SabreTools.Serialization.Wrappers.MoPaQ? wrapper) : base(wrapper) { } /// - 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 wrapper var mpq = SabreTools.Serialization.Wrappers.MoPaQ.Create(stream); diff --git a/BinaryObjectScanner/FileType/MicrosoftCAB.cs b/BinaryObjectScanner/FileType/MicrosoftCAB.cs index 0e65fbe2..3b978ed6 100644 --- a/BinaryObjectScanner/FileType/MicrosoftCAB.cs +++ b/BinaryObjectScanner/FileType/MicrosoftCAB.cs @@ -1,25 +1,17 @@ using System.IO; -using BinaryObjectScanner.Interfaces; namespace BinaryObjectScanner.FileType { /// /// Microsoft cabinet file /// - public class MicrosoftCAB : IExtractable + public class MicrosoftCAB : ExtractableBase { /// - 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 MicrosoftCAB(SabreTools.Serialization.Wrappers.MicrosoftCabinet? wrapper) : base(wrapper) { } /// - 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 wrapper var mscab = SabreTools.Serialization.Wrappers.MicrosoftCabinet.Create(stream); diff --git a/BinaryObjectScanner/FileType/PAK.cs b/BinaryObjectScanner/FileType/PAK.cs index 86c80503..e9867c42 100644 --- a/BinaryObjectScanner/FileType/PAK.cs +++ b/BinaryObjectScanner/FileType/PAK.cs @@ -1,25 +1,17 @@ using System.IO; -using BinaryObjectScanner.Interfaces; namespace BinaryObjectScanner.FileType { /// /// Half-Life Package File /// - public class PAK : IExtractable + public class PAK : ExtractableBase { /// - 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 PAK(SabreTools.Serialization.Wrappers.PAK? wrapper) : base(wrapper) { } /// - 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 wrapper var pak = SabreTools.Serialization.Wrappers.PAK.Create(stream); diff --git a/BinaryObjectScanner/FileType/PFF.cs b/BinaryObjectScanner/FileType/PFF.cs index bf2e0e62..7fbf944a 100644 --- a/BinaryObjectScanner/FileType/PFF.cs +++ b/BinaryObjectScanner/FileType/PFF.cs @@ -1,25 +1,17 @@ using System.IO; -using BinaryObjectScanner.Interfaces; namespace BinaryObjectScanner.FileType { /// /// NovaLogic Game Archive Format /// - public class PFF : IExtractable + public class PFF : ExtractableBase { /// - 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 PFF(SabreTools.Serialization.Wrappers.PFF? wrapper) : base(wrapper) { } /// - 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 wrapper var pff = SabreTools.Serialization.Wrappers.PFF.Create(stream); diff --git a/BinaryObjectScanner/FileType/PKZIP.cs b/BinaryObjectScanner/FileType/PKZIP.cs index 3fbccbb6..c7b8ab01 100644 --- a/BinaryObjectScanner/FileType/PKZIP.cs +++ b/BinaryObjectScanner/FileType/PKZIP.cs @@ -1,25 +1,17 @@ using System.IO; -using BinaryObjectScanner.Interfaces; namespace BinaryObjectScanner.FileType { /// /// PKWARE ZIP archive and derivatives /// - public class PKZIP : IExtractable + public class PKZIP : ExtractableBase { /// - 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 PKZIP(SabreTools.Serialization.Wrappers.PKZIP? wrapper) : base(wrapper) { } /// - 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 wrapper var pkzip = SabreTools.Serialization.Wrappers.PKZIP.Create(stream); diff --git a/BinaryObjectScanner/FileType/Quantum.cs b/BinaryObjectScanner/FileType/Quantum.cs index 2638ca07..dfd88d0a 100644 --- a/BinaryObjectScanner/FileType/Quantum.cs +++ b/BinaryObjectScanner/FileType/Quantum.cs @@ -1,25 +1,17 @@ using System.IO; -using BinaryObjectScanner.Interfaces; namespace BinaryObjectScanner.FileType { /// /// Quantum Archive /// - public class Quantum : IExtractable + public class Quantum : ExtractableBase { /// - 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 Quantum(SabreTools.Serialization.Wrappers.Quantum? wrapper) : base(wrapper) { } /// - 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 wrapper var qtm = SabreTools.Serialization.Wrappers.Quantum.Create(stream); diff --git a/BinaryObjectScanner/FileType/RAR.cs b/BinaryObjectScanner/FileType/RAR.cs index eb6f3d77..2f76bb02 100644 --- a/BinaryObjectScanner/FileType/RAR.cs +++ b/BinaryObjectScanner/FileType/RAR.cs @@ -1,25 +1,17 @@ using System.IO; -using BinaryObjectScanner.Interfaces; namespace BinaryObjectScanner.FileType { /// /// RAR archive /// - public class RAR : IExtractable + public class RAR : ExtractableBase { /// - 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 RAR(SabreTools.Serialization.Wrappers.RAR? wrapper) : base(wrapper) { } /// - public bool Extract(Stream? stream, string file, string outDir, bool includeDebug) + public override bool Extract(Stream? stream, string file, string outDir, bool includeDebug) { // Handle invalid inputs if (stream == null || stream.Length == 0) diff --git a/BinaryObjectScanner/FileType/SGA.cs b/BinaryObjectScanner/FileType/SGA.cs index dd4d34bd..420c798d 100644 --- a/BinaryObjectScanner/FileType/SGA.cs +++ b/BinaryObjectScanner/FileType/SGA.cs @@ -1,25 +1,17 @@ using System.IO; -using BinaryObjectScanner.Interfaces; namespace BinaryObjectScanner.FileType { /// /// SGA game archive /// - public class SGA : IExtractable + public class SGA : ExtractableBase { /// - 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 SGA(SabreTools.Serialization.Wrappers.SGA? wrapper) : base(wrapper) { } /// - 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 wrapper var sga = SabreTools.Serialization.Wrappers.SGA.Create(stream); diff --git a/BinaryObjectScanner/FileType/SevenZip.cs b/BinaryObjectScanner/FileType/SevenZip.cs index 556c7aa1..8553acce 100644 --- a/BinaryObjectScanner/FileType/SevenZip.cs +++ b/BinaryObjectScanner/FileType/SevenZip.cs @@ -1,25 +1,17 @@ using System.IO; -using BinaryObjectScanner.Interfaces; namespace BinaryObjectScanner.FileType { /// /// 7-zip archive /// - public class SevenZip : IExtractable + public class SevenZip : ExtractableBase { /// - 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 SevenZip(SabreTools.Serialization.Wrappers.SevenZip? wrapper) : base(wrapper) { } /// - public bool Extract(Stream? stream, string file, string outDir, bool includeDebug) + public override bool Extract(Stream? stream, string file, string outDir, bool includeDebug) { // Handle invalid inputs if (stream == null || stream.Length == 0) diff --git a/BinaryObjectScanner/FileType/TapeArchive.cs b/BinaryObjectScanner/FileType/TapeArchive.cs index 02f0be43..bbd164eb 100644 --- a/BinaryObjectScanner/FileType/TapeArchive.cs +++ b/BinaryObjectScanner/FileType/TapeArchive.cs @@ -1,25 +1,17 @@ using System.IO; -using BinaryObjectScanner.Interfaces; namespace BinaryObjectScanner.FileType { /// /// Tape archive /// - public class TapeArchive : IExtractable + public class TapeArchive : ExtractableBase { /// - 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 TapeArchive(SabreTools.Serialization.Wrappers.TapeArchive? wrapper) : base(wrapper) { } /// - 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 wrapper var tar = SabreTools.Serialization.Wrappers.TapeArchive.Create(stream); diff --git a/BinaryObjectScanner/FileType/VBSP.cs b/BinaryObjectScanner/FileType/VBSP.cs index 32cd9829..be0984c5 100644 --- a/BinaryObjectScanner/FileType/VBSP.cs +++ b/BinaryObjectScanner/FileType/VBSP.cs @@ -1,25 +1,17 @@ using System.IO; -using BinaryObjectScanner.Interfaces; namespace BinaryObjectScanner.FileType { /// /// Half-Life 2 Level /// - public class VBSP : IExtractable + public class VBSP : ExtractableBase { /// - 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 VBSP(SabreTools.Serialization.Wrappers.VBSP? wrapper) : base(wrapper) { } /// - 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 wrapper var vbsp = SabreTools.Serialization.Wrappers.VBSP.Create(stream); diff --git a/BinaryObjectScanner/FileType/VPK.cs b/BinaryObjectScanner/FileType/VPK.cs index 347d3659..e1583bd6 100644 --- a/BinaryObjectScanner/FileType/VPK.cs +++ b/BinaryObjectScanner/FileType/VPK.cs @@ -1,25 +1,17 @@ using System.IO; -using BinaryObjectScanner.Interfaces; namespace BinaryObjectScanner.FileType { /// /// Valve Package File /// - public class VPK : IExtractable + public class VPK : ExtractableBase { /// - 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 VPK(SabreTools.Serialization.Wrappers.VPK? wrapper) : base(wrapper) { } /// - 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 wrapper var vpk = SabreTools.Serialization.Wrappers.VPK.Create(stream); diff --git a/BinaryObjectScanner/FileType/WAD3.cs b/BinaryObjectScanner/FileType/WAD3.cs index 78f7fac9..d56f7950 100644 --- a/BinaryObjectScanner/FileType/WAD3.cs +++ b/BinaryObjectScanner/FileType/WAD3.cs @@ -1,25 +1,17 @@ using System.IO; -using BinaryObjectScanner.Interfaces; namespace BinaryObjectScanner.FileType { /// /// Half-Life Texture Package File /// - public class WAD3 : IExtractable + public class WAD3 : ExtractableBase { /// - 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 WAD3(SabreTools.Serialization.Wrappers.WAD3? wrapper) : base(wrapper) { } /// - 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 wrapper var wad = SabreTools.Serialization.Wrappers.WAD3.Create(stream); diff --git a/BinaryObjectScanner/FileType/XZ.cs b/BinaryObjectScanner/FileType/XZ.cs index f05aa63a..5715983c 100644 --- a/BinaryObjectScanner/FileType/XZ.cs +++ b/BinaryObjectScanner/FileType/XZ.cs @@ -1,25 +1,17 @@ using System.IO; -using BinaryObjectScanner.Interfaces; namespace BinaryObjectScanner.FileType { /// /// xz archive /// - public class XZ : IExtractable + public class XZ : ExtractableBase { /// - 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 XZ(SabreTools.Serialization.Wrappers.XZ? wrapper) : base(wrapper) { } /// - public bool Extract(Stream? stream, string file, string outDir, bool includeDebug) + public override bool Extract(Stream? stream, string file, string outDir, bool includeDebug) { // Handle invalid inputs if (stream == null || stream.Length == 0) diff --git a/BinaryObjectScanner/FileType/XZP.cs b/BinaryObjectScanner/FileType/XZP.cs index cf852ba9..9cc9bb81 100644 --- a/BinaryObjectScanner/FileType/XZP.cs +++ b/BinaryObjectScanner/FileType/XZP.cs @@ -1,25 +1,17 @@ using System.IO; -using BinaryObjectScanner.Interfaces; namespace BinaryObjectScanner.FileType { /// /// XBox Package File /// - public class XZP : IExtractable + public class XZP : ExtractableBase { /// - 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 XZP(SabreTools.Serialization.Wrappers.XZP? wrapper) : base(wrapper) { } /// - 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 wrapper var xzp = SabreTools.Serialization.Wrappers.XZP.Create(stream);