diff --git a/BinaryObjectScanner.Compression/BinaryObjectScanner.Compression.csproj b/BinaryObjectScanner.Compression/BinaryObjectScanner.Compression.csproj
index 0c7b1816..de312edf 100644
--- a/BinaryObjectScanner.Compression/BinaryObjectScanner.Compression.csproj
+++ b/BinaryObjectScanner.Compression/BinaryObjectScanner.Compression.csproj
@@ -35,7 +35,7 @@
-
+
diff --git a/BinaryObjectScanner.Printing/BinaryObjectScanner.Printing.csproj b/BinaryObjectScanner.Printing/BinaryObjectScanner.Printing.csproj
index 327828d7..34223c83 100644
--- a/BinaryObjectScanner.Printing/BinaryObjectScanner.Printing.csproj
+++ b/BinaryObjectScanner.Printing/BinaryObjectScanner.Printing.csproj
@@ -26,8 +26,8 @@
-
-
+
+
diff --git a/BinaryObjectScanner.Wrappers/AACSMediaKeyBlock.cs b/BinaryObjectScanner.Wrappers/AACSMediaKeyBlock.cs
deleted file mode 100644
index 2acb9377..00000000
--- a/BinaryObjectScanner.Wrappers/AACSMediaKeyBlock.cs
+++ /dev/null
@@ -1,108 +0,0 @@
-using System.IO;
-using System.Text;
-using SabreTools.Models.AACS;
-
-namespace BinaryObjectScanner.Wrappers
-{
- public class AACSMediaKeyBlock : WrapperBase
- {
- #region Descriptive Properties
-
- ///
- public override string DescriptionString => "AACS Media Key Block";
-
- #endregion
-
- #region Constructors
-
- ///
-#if NET48
- public AACSMediaKeyBlock(MediaKeyBlock model, byte[] data, int offset)
-#else
- public AACSMediaKeyBlock(MediaKeyBlock? model, byte[]? data, int offset)
-#endif
- : base(model, data, offset)
- {
- // All logic is handled by the base class
- }
-
- ///
-#if NET48
- public AACSMediaKeyBlock(MediaKeyBlock model, Stream data)
-#else
- public AACSMediaKeyBlock(MediaKeyBlock? model, Stream? data)
-#endif
- : base(model, data)
- {
- // All logic is handled by the base class
- }
-
- ///
- /// Create an AACS media key block from a byte array and offset
- ///
- /// Byte array representing the archive
- /// Offset within the array to parse
- /// An AACS media key block wrapper on success, null on failure
-#if NET48
- public static AACSMediaKeyBlock Create(byte[] data, int offset)
-#else
- public static AACSMediaKeyBlock? Create(byte[]? data, int offset)
-#endif
- {
- // If the data is invalid
- if (data == null)
- return null;
-
- // If the offset is out of bounds
- if (offset < 0 || offset >= data.Length)
- return null;
-
- // Create a memory stream and use that
- MemoryStream dataStream = new MemoryStream(data, offset, data.Length - offset);
- return Create(dataStream);
- }
-
- ///
- /// Create an AACS media key block from a Stream
- ///
- /// Stream representing the archive
- /// An AACS media key block wrapper on success, null on failure
-#if NET48
- public static AACSMediaKeyBlock Create(Stream data)
-#else
- public static AACSMediaKeyBlock? Create(Stream? data)
-#endif
- {
- // If the data is invalid
- if (data == null || data.Length == 0 || !data.CanSeek || !data.CanRead)
- return null;
-
- var mediaKeyBlock = new SabreTools.Serialization.Streams.AACS().Deserialize(data);
- if (mediaKeyBlock == null)
- return null;
-
- try
- {
- return new AACSMediaKeyBlock(mediaKeyBlock, data);
- }
- catch
- {
- return null;
- }
- }
-
- #endregion
-
- #region Printing
-
- ///
- public override StringBuilder PrettyPrint()
- {
- StringBuilder builder = new StringBuilder();
- Printing.AACSMediaKeyBlock.Print(builder, this.Model);
- return builder;
- }
-
- #endregion
- }
-}
\ No newline at end of file
diff --git a/BinaryObjectScanner.Wrappers/BDPlusSVM.cs b/BinaryObjectScanner.Wrappers/BDPlusSVM.cs
deleted file mode 100644
index f886e496..00000000
--- a/BinaryObjectScanner.Wrappers/BDPlusSVM.cs
+++ /dev/null
@@ -1,108 +0,0 @@
-using System.IO;
-using System.Text;
-using SabreTools.Models.BDPlus;
-
-namespace BinaryObjectScanner.Wrappers
-{
- public class BDPlusSVM : WrapperBase
- {
- #region Descriptive Properties
-
- ///
- public override string DescriptionString => "BD+ SVM";
-
- #endregion
-
- #region Constructors
-
- ///
-#if NET48
- public BDPlusSVM(SVM model, byte[] data, int offset)
-#else
- public BDPlusSVM(SVM? model, byte[]? data, int offset)
-#endif
- : base(model, data, offset)
- {
- // All logic is handled by the base class
- }
-
- ///
-#if NET48
- public BDPlusSVM(SVM model, Stream data)
-#else
- public BDPlusSVM(SVM? model, Stream? data)
-#endif
- : base(model, data)
- {
- // All logic is handled by the base class
- }
-
- ///
- /// Create a BD+ SVM from a byte array and offset
- ///
- /// Byte array representing the archive
- /// Offset within the array to parse
- /// A BD+ SVM wrapper on success, null on failure
-#if NET48
- public static BDPlusSVM Create(byte[] data, int offset)
-#else
- public static BDPlusSVM? Create(byte[]? data, int offset)
-#endif
- {
- // If the data is invalid
- if (data == null)
- return null;
-
- // If the offset is out of bounds
- if (offset < 0 || offset >= data.Length)
- return null;
-
- // Create a memory stream and use that
- MemoryStream dataStream = new MemoryStream(data, offset, data.Length - offset);
- return Create(dataStream);
- }
-
- ///
- /// Create a BD+ SVM from a Stream
- ///
- /// Stream representing the archive
- /// A BD+ SVM wrapper on success, null on failure
-#if NET48
- public static BDPlusSVM Create(Stream data)
-#else
- public static BDPlusSVM? Create(Stream? data)
-#endif
- {
- // If the data is invalid
- if (data == null || data.Length == 0 || !data.CanSeek || !data.CanRead)
- return null;
-
- var svm = new SabreTools.Serialization.Streams.BDPlus().Deserialize(data);
- if (svm == null)
- return null;
-
- try
- {
- return new BDPlusSVM(svm, data);
- }
- catch
- {
- return null;
- }
- }
-
- #endregion
-
- #region Printing
-
- ///
- public override StringBuilder PrettyPrint()
- {
- StringBuilder builder = new StringBuilder();
- Printing.BDPlusSVM.Print(builder, this.Model);
- return builder;
- }
-
- #endregion
- }
-}
\ No newline at end of file
diff --git a/BinaryObjectScanner.Wrappers/BFPK.cs b/BinaryObjectScanner.Wrappers/BFPK.cs
deleted file mode 100644
index 996d20b7..00000000
--- a/BinaryObjectScanner.Wrappers/BFPK.cs
+++ /dev/null
@@ -1,205 +0,0 @@
-using System.IO;
-using System.Text;
-using SharpCompress.Compressors;
-using SharpCompress.Compressors.Deflate;
-
-namespace BinaryObjectScanner.Wrappers
-{
- public class BFPK : WrapperBase
- {
- #region Descriptive Properties
-
- ///
- public override string DescriptionString => "BFPK Archive";
-
- #endregion
-
- #region Constructors
-
- ///
-#if NET48
- public BFPK(SabreTools.Models.BFPK.Archive model, byte[] data, int offset)
-#else
- public BFPK(SabreTools.Models.BFPK.Archive? model, byte[]? data, int offset)
-#endif
- : base(model, data, offset)
- {
- // All logic is handled by the base class
- }
-
- ///
-#if NET48
- public BFPK(SabreTools.Models.BFPK.Archive model, Stream data)
-#else
- public BFPK(SabreTools.Models.BFPK.Archive? model, Stream? data)
-#endif
- : base(model, data)
- {
- // All logic is handled by the base class
- }
-
- ///
- /// Create a BFPK archive from a byte array and offset
- ///
- /// Byte array representing the archive
- /// Offset within the array to parse
- /// A BFPK archive wrapper on success, null on failure
-#if NET48
- public static BFPK Create(byte[] data, int offset)
-#else
- public static BFPK? Create(byte[]? data, int offset)
-#endif
- {
- // If the data is invalid
- if (data == null)
- return null;
-
- // If the offset is out of bounds
- if (offset < 0 || offset >= data.Length)
- return null;
-
- // Create a memory stream and use that
- MemoryStream dataStream = new MemoryStream(data, offset, data.Length - offset);
- return Create(dataStream);
- }
-
- ///
- /// Create a BFPK archive from a Stream
- ///
- /// Stream representing the archive
- /// A BFPK archive wrapper on success, null on failure
-#if NET48
- public static BFPK Create(Stream data)
-#else
- public static BFPK? Create(Stream? data)
-#endif
- {
- // If the data is invalid
- if (data == null || data.Length == 0 || !data.CanSeek || !data.CanRead)
- return null;
-
- var archive = new SabreTools.Serialization.Streams.BFPK().Deserialize(data);
- if (archive == null)
- return null;
-
- try
- {
- return new BFPK(archive, data);
- }
- catch
- {
- return null;
- }
- }
-
- #endregion
-
- #region Data
-
- ///
- /// Extract all files from the BFPK to an output directory
- ///
- /// Output directory to write to
- /// True if all files extracted, false otherwise
- public bool ExtractAll(string outputDirectory)
- {
- // If we have no files
- if (this.Model.Files == null || this.Model.Files.Length == 0)
- return false;
-
- // Loop through and extract all files to the output
- bool allExtracted = true;
- for (int i = 0; i < this.Model.Files.Length; i++)
- {
- allExtracted &= ExtractFile(i, outputDirectory);
- }
-
- return allExtracted;
- }
-
- ///
- /// Extract a file from the BFPK to an output directory by index
- ///
- /// File index to extract
- /// Output directory to write to
- /// True if the file extracted, false otherwise
- public bool ExtractFile(int index, string outputDirectory)
- {
- // If we have no files
- if (this.Model.Files == null || this.Model.Files.Length == 0)
- return false;
-
- // If we have an invalid index
- if (index < 0 || index >= this.Model.Files.Length)
- return false;
-
- // Get the file information
- var file = this.Model.Files[index];
- if (file == null)
- return false;
-
- // Get the read index and length
- int offset = file.Offset + 4;
- int compressedSize = file.CompressedSize;
-
- // Some files can lack the length prefix
- if (compressedSize > GetEndOfFile())
- {
- offset -= 4;
- compressedSize = file.UncompressedSize;
- }
-
- try
- {
- // Ensure the output directory exists
- Directory.CreateDirectory(outputDirectory);
-
- // Create the output path
- string filePath = Path.Combine(outputDirectory, file.Name ?? $"file{index}");
- using (FileStream fs = File.OpenWrite(filePath))
- {
- // Read the data block
-#if NET48
- byte[] data = ReadFromDataSource(offset, compressedSize);
-#else
- byte[]? data = ReadFromDataSource(offset, compressedSize);
-#endif
- if (data == null)
- return false;
-
- // If we have uncompressed data
- if (compressedSize == file.UncompressedSize)
- {
- fs.Write(data, 0, compressedSize);
- }
- else
- {
- MemoryStream ms = new MemoryStream(data);
- ZlibStream zs = new ZlibStream(ms, CompressionMode.Decompress);
- zs.CopyTo(fs);
- }
- }
-
- return true;
- }
- catch
- {
- return false;
- }
- }
-
- #endregion
-
- #region Printing
-
- ///
- public override StringBuilder PrettyPrint()
- {
- StringBuilder builder = new StringBuilder();
- Printing.BFPK.Print(builder, this.Model);
- return builder;
- }
-
- #endregion
- }
-}
\ No newline at end of file
diff --git a/BinaryObjectScanner.Wrappers/BSP.cs b/BinaryObjectScanner.Wrappers/BSP.cs
deleted file mode 100644
index d57f4b30..00000000
--- a/BinaryObjectScanner.Wrappers/BSP.cs
+++ /dev/null
@@ -1,389 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Text;
-using static SabreTools.Models.BSP.Constants;
-
-namespace BinaryObjectScanner.Wrappers
-{
- public class BSP : WrapperBase
- {
- #region Descriptive Properties
-
- ///
- public override string DescriptionString => "Half-Life Level (BSP)";
-
- #endregion
-
- #region Constructors
-
- ///
-#if NET48
- public BSP(SabreTools.Models.BSP.File model, byte[] data, int offset)
-#else
- public BSP(SabreTools.Models.BSP.File? model, byte[]? data, int offset)
-#endif
- : base(model, data, offset)
- {
- // All logic is handled by the base class
- }
-
- ///
-#if NET48
- public BSP(SabreTools.Models.BSP.File model, Stream data)
-#else
- public BSP(SabreTools.Models.BSP.File? model, Stream? data)
-#endif
- : base(model, data)
- {
- // All logic is handled by the base class
- }
-
- ///
- /// Create a BSP from a byte array and offset
- ///
- /// Byte array representing the BSP
- /// Offset within the array to parse
- /// A BSP wrapper on success, null on failure
-#if NET48
- public static BSP Create(byte[] data, int offset)
-#else
- public static BSP? Create(byte[]? data, int offset)
-#endif
- {
- // If the data is invalid
- if (data == null)
- return null;
-
- // If the offset is out of bounds
- if (offset < 0 || offset >= data.Length)
- return null;
-
- // Create a memory stream and use that
- MemoryStream dataStream = new MemoryStream(data, offset, data.Length - offset);
- return Create(dataStream);
- }
-
- ///
- /// Create a BSP from a Stream
- ///
- /// Stream representing the BSP
- /// An BSP wrapper on success, null on failure
-#if NET48
- public static BSP Create(Stream data)
-#else
- public static BSP? Create(Stream? data)
-#endif
- {
- // If the data is invalid
- if (data == null || data.Length == 0 || !data.CanSeek || !data.CanRead)
- return null;
-
- var file = new SabreTools.Serialization.Streams.BSP().Deserialize(data);
- if (file == null)
- return null;
-
- try
- {
- return new BSP(file, data);
- }
- catch
- {
- return null;
- }
- }
-
- #endregion
-
- #region Printing
-
- ///
- public override StringBuilder PrettyPrint()
- {
- StringBuilder builder = new StringBuilder();
- Printing.BSP.Print(builder, this.Model);
- return builder;
- }
-
- #endregion
-
- #region Extraction
-
- ///
- /// Extract all lumps from the BSP to an output directory
- ///
- /// Output directory to write to
- /// True if all lumps extracted, false otherwise
- public bool ExtractAllLumps(string outputDirectory)
- {
- // If we have no lumps
- if (this.Model.Lumps == null || this.Model.Lumps.Length == 0)
- return false;
-
- // Loop through and extract all lumps to the output
- bool allExtracted = true;
- for (int i = 0; i < this.Model.Lumps.Length; i++)
- {
- allExtracted &= ExtractLump(i, outputDirectory);
- }
-
- return allExtracted;
- }
-
- ///
- /// Extract a lump from the BSP to an output directory by index
- ///
- /// Lump index to extract
- /// Output directory to write to
- /// True if the lump extracted, false otherwise
- public bool ExtractLump(int index, string outputDirectory)
- {
- // If we have no lumps
- if (this.Model.Lumps == null || this.Model.Lumps.Length == 0)
- return false;
-
- // If the lumps index is invalid
- if (index < 0 || index >= this.Model.Lumps.Length)
- return false;
-
- // Get the lump
- var lump = this.Model.Lumps[index];
- if (lump == null)
- return false;
-
- // Read the data
-#if NET48
- byte[] data = ReadFromDataSource((int)lump.Offset, (int)lump.Length);
-#else
- byte[]? data = ReadFromDataSource((int)lump.Offset, (int)lump.Length);
-#endif
- if (data == null)
- return false;
-
- // Create the filename
- string filename = $"lump_{index}.bin";
- switch (index)
- {
- case HL_BSP_LUMP_ENTITIES:
- filename = "entities.ent";
- break;
- case HL_BSP_LUMP_TEXTUREDATA:
- filename = "texture_data.bin";
- break;
- }
-
- // If we have an invalid output directory
- if (string.IsNullOrWhiteSpace(outputDirectory))
- return false;
-
- // Create the full output path
- filename = Path.Combine(outputDirectory, filename);
-
- // Ensure the output directory is created
-#if NET48
- string directoryName = Path.GetDirectoryName(filename);
-#else
- string? directoryName = Path.GetDirectoryName(filename);
-#endif
- if (directoryName != null)
- Directory.CreateDirectory(directoryName);
-
- // Try to write the data
- try
- {
- // Open the output file for writing
- using (Stream fs = File.OpenWrite(filename))
- {
- fs.Write(data, 0, data.Length);
- }
- }
- catch
- {
- return false;
- }
-
- return true;
- }
-
- ///
- /// Extract all textures from the BSP to an output directory
- ///
- /// Output directory to write to
- /// True if all textures extracted, false otherwise
- public bool ExtractAllTextures(string outputDirectory)
- {
- // If we have no textures
- if (this.Model.TextureHeader?.Offsets == null || this.Model.TextureHeader.Offsets.Length == 0)
- return false;
-
- // Loop through and extract all lumps to the output
- bool allExtracted = true;
- for (int i = 0; i < this.Model.TextureHeader.Offsets.Length; i++)
- {
- allExtracted &= ExtractTexture(i, outputDirectory);
- }
-
- return allExtracted;
- }
-
- ///
- /// Extract a texture from the BSP to an output directory by index
- ///
- /// Lump index to extract
- /// Output directory to write to
- /// True if the texture extracted, false otherwise
- public bool ExtractTexture(int index, string outputDirectory)
- {
- // If we have no textures
- if (this.Model.Textures == null || this.Model.Textures.Length == 0)
- return false;
-
- // If the texture index is invalid
- if (index < 0 || index >= this.Model.Textures.Length)
- return false;
-
- // Get the texture
- var texture = this.Model.Textures[index];
- if (texture == null)
- return false;
-
- // Read the data
-#if NET48
- byte[] data = CreateTextureData(texture);
-#else
- byte[]? data = CreateTextureData(texture);
-#endif
- if (data == null)
- return false;
-
- // Create the filename
- string filename = $"{texture.Name}.bmp";
-
- // If we have an invalid output directory
- if (string.IsNullOrWhiteSpace(outputDirectory))
- return false;
-
- // Create the full output path
- filename = Path.Combine(outputDirectory, filename);
-
- // Ensure the output directory is created
-#if NET48
- string directoryName = Path.GetDirectoryName(filename);
-#else
- string? directoryName = Path.GetDirectoryName(filename);
-#endif
- if (directoryName != null)
- Directory.CreateDirectory(directoryName);
-
- // Try to write the data
- try
- {
- // Open the output file for writing
- using (Stream fs = File.OpenWrite(filename))
- {
- fs.Write(data, 0, data.Length);
- }
- }
- catch
- {
- return false;
- }
-
- return true;
- }
-
- ///
- /// Create a bitmap from the texture and palette data
- ///
- /// Texture object to format
- /// Byte array representing the texture as a bitmap
-#if NET48
- private static byte[] CreateTextureData(SabreTools.Models.BSP.Texture texture)
-#else
- private static byte[]? CreateTextureData(SabreTools.Models.BSP.Texture texture)
-#endif
- {
- // If there's no palette data
- if (texture.PaletteData == null || texture.PaletteData.Length == 0)
- return null;
-
- // If there's no texture data
- if (texture.TextureData == null || texture.TextureData.Length == 0)
- return null;
-
- // Create the bitmap file header
- var fileHeader = new SabreTools.Models.BMP.BITMAPFILEHEADER()
- {
- Type = ('M' << 8) | 'B',
- Size = 14 + 40 + (texture.PaletteSize * 4) + (texture.Width * texture.Height),
- OffBits = 14 + 40 + (texture.PaletteSize * 4),
- };
-
- // Create the bitmap info header
- var infoHeader = new SabreTools.Models.BMP.BITMAPINFOHEADER
- {
- Size = 40,
- Width = (int)texture.Width,
- Height = (int)texture.Height,
- Planes = 1,
- BitCount = 8,
- SizeImage = 0,
- ClrUsed = texture.PaletteSize,
- ClrImportant = texture.PaletteSize,
- };
-
- // Reformat the palette data
- byte[] paletteData = new byte[texture.PaletteSize * 4];
- for (uint i = 0; i < texture.PaletteSize; i++)
- {
- paletteData[i * 4 + 0] = texture.PaletteData[i * 3 + 2];
- paletteData[i * 4 + 1] = texture.PaletteData[i * 3 + 1];
- paletteData[i * 4 + 2] = texture.PaletteData[i * 3 + 0];
- paletteData[i * 4 + 3] = 0;
- }
-
- // Reformat the pixel data
- byte[] pixelData = new byte[texture.Width * texture.Height];
- for (uint i = 0; i < texture.Width; i++)
- {
- for (uint j = 0; j < texture.Height; j++)
- {
- pixelData[i + ((texture.Height - 1 - j) * texture.Width)] = texture.TextureData[i + j * texture.Width];
- }
- }
-
- // Build the file data
- List buffer = new List();
-
- // Bitmap file header
- buffer.AddRange(BitConverter.GetBytes(fileHeader.Type));
- buffer.AddRange(BitConverter.GetBytes(fileHeader.Size));
- buffer.AddRange(BitConverter.GetBytes(fileHeader.Reserved1));
- buffer.AddRange(BitConverter.GetBytes(fileHeader.Reserved2));
- buffer.AddRange(BitConverter.GetBytes(fileHeader.OffBits));
-
- // Bitmap info header
- buffer.AddRange(BitConverter.GetBytes(infoHeader.Size));
- buffer.AddRange(BitConverter.GetBytes(infoHeader.Width));
- buffer.AddRange(BitConverter.GetBytes(infoHeader.Height));
- buffer.AddRange(BitConverter.GetBytes(infoHeader.Planes));
- buffer.AddRange(BitConverter.GetBytes(infoHeader.BitCount));
- buffer.AddRange(BitConverter.GetBytes(infoHeader.Compression));
- buffer.AddRange(BitConverter.GetBytes(infoHeader.SizeImage));
- buffer.AddRange(BitConverter.GetBytes(infoHeader.XPelsPerMeter));
- buffer.AddRange(BitConverter.GetBytes(infoHeader.YPelsPerMeter));
- buffer.AddRange(BitConverter.GetBytes(infoHeader.ClrUsed));
- buffer.AddRange(BitConverter.GetBytes(infoHeader.ClrImportant));
-
- // Palette data
- buffer.AddRange(paletteData);
-
- // Pixel data
- buffer.AddRange(pixelData);
-
- return buffer.ToArray();
- }
-
- #endregion
- }
-}
\ No newline at end of file
diff --git a/BinaryObjectScanner.Wrappers/BinaryObjectScanner.Wrappers.csproj b/BinaryObjectScanner.Wrappers/BinaryObjectScanner.Wrappers.csproj
index 2827f825..c8f0dd20 100644
--- a/BinaryObjectScanner.Wrappers/BinaryObjectScanner.Wrappers.csproj
+++ b/BinaryObjectScanner.Wrappers/BinaryObjectScanner.Wrappers.csproj
@@ -30,8 +30,8 @@
-
-
+
+
diff --git a/BinaryObjectScanner.Wrappers/CFB.cs b/BinaryObjectScanner.Wrappers/CFB.cs
deleted file mode 100644
index 698541eb..00000000
--- a/BinaryObjectScanner.Wrappers/CFB.cs
+++ /dev/null
@@ -1,365 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Text;
-
-namespace BinaryObjectScanner.Wrappers
-{
- public class CFB : WrapperBase
- {
- #region Descriptive Properties
-
- ///
- public override string DescriptionString => "Compact File Binary";
-
- #endregion
-
- #region Extension Properties
-
- ///
- /// Normal sector size in bytes
- ///
-#if NET48
- public long SectorSize => (long)Math.Pow(2, this.Model.Header.SectorShift);
-#else
- public long SectorSize => (long)Math.Pow(2, this.Model.Header?.SectorShift ?? 0);
-#endif
-
- ///
- /// Mini sector size in bytes
- ///
-#if NET48
- public long MiniSectorSize => (long)Math.Pow(2, this.Model.Header.MiniSectorShift);
-#else
- public long MiniSectorSize => (long)Math.Pow(2, this.Model.Header?.MiniSectorShift ?? 0);
-#endif
-
- #endregion
-
- #region Constructors
-
- ///
-#if NET48
- public CFB(SabreTools.Models.CFB.Binary model, byte[] data, int offset)
-#else
- public CFB(SabreTools.Models.CFB.Binary? model, byte[]? data, int offset)
-#endif
- : base(model, data, offset)
- {
- // All logic is handled by the base class
- }
-
- ///
-#if NET48
- public CFB(SabreTools.Models.CFB.Binary model, Stream data)
-#else
- public CFB(SabreTools.Models.CFB.Binary? model, Stream? data)
-#endif
- : base(model, data)
- {
- // All logic is handled by the base class
- }
-
- ///
- /// Create a Compound File Binary from a byte array and offset
- ///
- /// Byte array representing the archive
- /// Offset within the array to parse
- /// A Compound File Binary wrapper on success, null on failure
-#if NET48
- public static CFB Create(byte[] data, int offset)
-#else
- public static CFB? Create(byte[]? data, int offset)
-#endif
- {
- // If the data is invalid
- if (data == null)
- return null;
-
- // If the offset is out of bounds
- if (offset < 0 || offset >= data.Length)
- return null;
-
- // Create a memory stream and use that
- MemoryStream dataStream = new MemoryStream(data, offset, data.Length - offset);
- return Create(dataStream);
- }
-
- ///
- /// Create a Compound File Binary from a Stream
- ///
- /// Stream representing the archive
- /// A Compound File Binary wrapper on success, null on failure
-#if NET48
- public static CFB Create(Stream data)
-#else
- public static CFB? Create(Stream? data)
-#endif
- {
- // If the data is invalid
- if (data == null || data.Length == 0 || !data.CanSeek || !data.CanRead)
- return null;
-
- var binary = new SabreTools.Serialization.Streams.CFB().Deserialize(data);
- if (binary == null)
- return null;
-
- try
- {
- return new CFB(binary, data);
- }
- catch
- {
- return null;
- }
- }
-
- #endregion
-
- #region FAT Sector Data
-
- ///
- /// Get the ordered FAT sector chain for a given starting sector
- ///
- /// Initial FAT sector
- /// Ordered list of sector numbers, null on error
-#if NET48
- public List GetFATSectorChain(SabreTools.Models.CFB.SectorNumber startingSector)
-#else
- public List? GetFATSectorChain(SabreTools.Models.CFB.SectorNumber? startingSector)
-#endif
- {
- // If we have an invalid sector
-#if NET48
- if (startingSector < 0 || this.Model.FATSectorNumbers == null || (long)startingSector >= this.Model.FATSectorNumbers.Length)
-#else
- if (startingSector == null || startingSector < 0 || this.Model.FATSectorNumbers == null || (long)startingSector >= this.Model.FATSectorNumbers.Length)
-#endif
- return null;
-
- // Setup the returned list
-#if NET48
- var sectors = new List { startingSector };
-#else
- var sectors = new List { startingSector };
-#endif
-
- var lastSector = startingSector;
- while (true)
- {
-#if NET6_0_OR_GREATER
- if (lastSector == null)
- break;
-#endif
-
- // Get the next sector from the lookup table
-#if NET48
- var nextSector = this.Model.FATSectorNumbers[(uint)lastSector];
-#else
- var nextSector = this.Model.FATSectorNumbers[(uint)lastSector!.Value];
-#endif
-
- // If we have an end of chain or free sector
- if (nextSector == SabreTools.Models.CFB.SectorNumber.ENDOFCHAIN || nextSector == SabreTools.Models.CFB.SectorNumber.FREESECT)
- break;
-
- // Add the next sector to the list and replace the last sector
- sectors.Add(nextSector);
- lastSector = nextSector;
- }
-
- return sectors;
- }
-
- ///
- /// Get the data for the FAT sector chain starting at a given starting sector
- ///
- /// Initial FAT sector
- /// Ordered list of sector numbers, null on error
-#if NET48
- public byte[] GetFATSectorChainData(SabreTools.Models.CFB.SectorNumber startingSector)
-#else
- public byte[]? GetFATSectorChainData(SabreTools.Models.CFB.SectorNumber startingSector)
-#endif
- {
- // Get the sector chain first
- var sectorChain = GetFATSectorChain(startingSector);
- if (sectorChain == null)
- return null;
-
- // Sequentially read the sectors
- var data = new List();
- for (int i = 0; i < sectorChain.Count; i++)
- {
- // Try to get the sector data offset
- int sectorDataOffset = (int)FATSectorToFileOffset(sectorChain[i]);
- if (sectorDataOffset < 0 || sectorDataOffset >= GetEndOfFile())
- return null;
-
- // Try to read the sector data
- var sectorData = ReadFromDataSource(sectorDataOffset, (int)SectorSize);
- if (sectorData == null)
- return null;
-
- // Add the sector data to the output
- data.AddRange(sectorData);
- }
-
- return data.ToArray();
- }
-
- ///
- /// Convert a FAT sector value to a byte offset
- ///
- /// Sector to convert
- /// File offset in bytes, -1 on error
-#if NET48
- public long FATSectorToFileOffset(SabreTools.Models.CFB.SectorNumber sector)
-#else
- public long FATSectorToFileOffset(SabreTools.Models.CFB.SectorNumber? sector)
-#endif
- {
- // If we have an invalid sector number
-#if NET48
- if (sector > SabreTools.Models.CFB.SectorNumber.MAXREGSECT)
-#else
- if (sector == null || sector > SabreTools.Models.CFB.SectorNumber.MAXREGSECT)
-#endif
- return -1;
-
- // Convert based on the sector shift value
- return (long)(sector + 1) * SectorSize;
- }
-
- #endregion
-
- #region Mini FAT Sector Data
-
- ///
- /// Get the ordered Mini FAT sector chain for a given starting sector
- ///
- /// Initial Mini FAT sector
- /// Ordered list of sector numbers, null on error
-#if NET48
- public List GetMiniFATSectorChain(SabreTools.Models.CFB.SectorNumber startingSector)
-#else
- public List? GetMiniFATSectorChain(SabreTools.Models.CFB.SectorNumber? startingSector)
-#endif
- {
- // If we have an invalid sector
-#if NET48
- if (startingSector < 0 || this.Model.MiniFATSectorNumbers == null || (long)startingSector >= this.Model.MiniFATSectorNumbers.Length)
-#else
- if (startingSector == null || startingSector < 0 || this.Model.MiniFATSectorNumbers == null || (long)startingSector >= this.Model.MiniFATSectorNumbers.Length)
-#endif
- return null;
-
- // Setup the returned list
-#if NET48
- var sectors = new List { startingSector };
-#else
- var sectors = new List { startingSector };
-#endif
-
- var lastSector = startingSector;
- while (true)
- {
-#if NET6_0_OR_GREATER
- if (lastSector == null)
- break;
-#endif
-
- // Get the next sector from the lookup table
-#if NET48
- var nextSector = this.Model.MiniFATSectorNumbers[(uint)lastSector];
-#else
- var nextSector = this.Model.MiniFATSectorNumbers[(uint)lastSector!.Value];
-#endif
-
- // If we have an end of chain or free sector
- if (nextSector == SabreTools.Models.CFB.SectorNumber.ENDOFCHAIN || nextSector == SabreTools.Models.CFB.SectorNumber.FREESECT)
- break;
-
- // Add the next sector to the list and replace the last sector
- sectors.Add(nextSector);
- lastSector = nextSector;
- }
-
- return sectors;
- }
-
- ///
- /// Get the data for the Mini FAT sector chain starting at a given starting sector
- ///
- /// Initial Mini FAT sector
- /// Ordered list of sector numbers, null on error
-#if NET48
- public byte[] GetMiniFATSectorChainData(SabreTools.Models.CFB.SectorNumber startingSector)
-#else
- public byte[]? GetMiniFATSectorChainData(SabreTools.Models.CFB.SectorNumber startingSector)
-#endif
- {
- // Get the sector chain first
- var sectorChain = GetMiniFATSectorChain(startingSector);
- if (sectorChain == null)
- return null;
-
- // Sequentially read the sectors
- var data = new List();
- for (int i = 0; i < sectorChain.Count; i++)
- {
- // Try to get the sector data offset
- int sectorDataOffset = (int)MiniFATSectorToFileOffset(sectorChain[i]);
- if (sectorDataOffset < 0 || sectorDataOffset >= GetEndOfFile())
- return null;
-
- // Try to read the sector data
- var sectorData = ReadFromDataSource(sectorDataOffset, (int)MiniSectorSize);
- if (sectorData == null)
- return null;
-
- // Add the sector data to the output
- data.AddRange(sectorData);
- }
-
- return data.ToArray();
- }
-
- ///
- /// Convert a Mini FAT sector value to a byte offset
- ///
- /// Sector to convert
- /// File offset in bytes, -1 on error
-#if NET48
- public long MiniFATSectorToFileOffset(SabreTools.Models.CFB.SectorNumber sector)
-#else
- public long MiniFATSectorToFileOffset(SabreTools.Models.CFB.SectorNumber? sector)
-#endif
- {
- // If we have an invalid sector number
-#if NET48
- if (sector > SabreTools.Models.CFB.SectorNumber.MAXREGSECT)
-#else
- if (sector == null || sector > SabreTools.Models.CFB.SectorNumber.MAXREGSECT)
-#endif
- return -1;
-
- // Convert based on the sector shift value
- return (long)(sector + 1) * MiniSectorSize;
- }
-
- #endregion
-
- #region Printing
-
- ///
- public override StringBuilder PrettyPrint()
- {
- StringBuilder builder = new StringBuilder();
- Printing.CFB.Print(builder, this.Model);
- return builder;
- }
-
- #endregion
- }
-}
\ No newline at end of file
diff --git a/BinaryObjectScanner.Wrappers/CIA.cs b/BinaryObjectScanner.Wrappers/CIA.cs
deleted file mode 100644
index 5604c818..00000000
--- a/BinaryObjectScanner.Wrappers/CIA.cs
+++ /dev/null
@@ -1,107 +0,0 @@
-using System.IO;
-using System.Text;
-
-namespace BinaryObjectScanner.Wrappers
-{
- public class CIA : WrapperBase
- {
- #region Descriptive Properties
-
- ///
- public override string DescriptionString => "CTR Importable Archive (CIA)";
-
- #endregion
-
- #region Constructors
-
- ///
-#if NET48
- public CIA(SabreTools.Models.N3DS.CIA model, byte[] data, int offset)
-#else
- public CIA(SabreTools.Models.N3DS.CIA? model, byte[]? data, int offset)
-#endif
- : base(model, data, offset)
- {
- // All logic is handled by the base class
- }
-
- ///
-#if NET48
- public CIA(SabreTools.Models.N3DS.CIA model, Stream data)
-#else
- public CIA(SabreTools.Models.N3DS.CIA? model, Stream? data)
-#endif
- : base(model, data)
- {
- // All logic is handled by the base class
- }
-
- ///
- /// Create a CIA archive from a byte array and offset
- ///
- /// Byte array representing the archive
- /// Offset within the array to parse
- /// A CIA archive wrapper on success, null on failure
-#if NET48
- public static CIA Create(byte[] data, int offset)
-#else
- public static CIA? Create(byte[]? data, int offset)
-#endif
- {
- // If the data is invalid
- if (data == null)
- return null;
-
- // If the offset is out of bounds
- if (offset < 0 || offset >= data.Length)
- return null;
-
- // Create a memory stream and use that
- MemoryStream dataStream = new MemoryStream(data, offset, data.Length - offset);
- return Create(dataStream);
- }
-
- ///
- /// Create a CIA archive from a Stream
- ///
- /// Stream representing the archive
- /// A CIA archive wrapper on success, null on failure
-#if NET48
- public static CIA Create(Stream data)
-#else
- public static CIA? Create(Stream? data)
-#endif
- {
- // If the data is invalid
- if (data == null || data.Length == 0 || !data.CanSeek || !data.CanRead)
- return null;
-
- var archive = new SabreTools.Serialization.Streams.CIA().Deserialize(data);
- if (archive == null)
- return null;
-
- try
- {
- return new CIA(archive, data);
- }
- catch
- {
- return null;
- }
- }
-
- #endregion
-
- #region Printing
-
- ///
- public override StringBuilder PrettyPrint()
- {
- StringBuilder builder = new StringBuilder();
- Printing.CIA.Print(builder, this.Model);
- return builder;
- }
-
- #endregion
- }
-}
\ No newline at end of file
diff --git a/BinaryObjectScanner.Wrappers/ConcreteInterfaceSerializer.cs b/BinaryObjectScanner.Wrappers/ConcreteInterfaceSerializer.cs
deleted file mode 100644
index ed062464..00000000
--- a/BinaryObjectScanner.Wrappers/ConcreteInterfaceSerializer.cs
+++ /dev/null
@@ -1,82 +0,0 @@
-#if NET6_0_OR_GREATER
-using System;
-using System.Reflection;
-using System.Text.Json;
-using System.Text.Json.Serialization;
-
-namespace BinaryObjectScanner.Wrappers
-{
- ///
- /// Serializer class for abstract classes
- ///
- ///
- internal class ConcreteAbstractSerializer : JsonConverterFactory
- {
- public override bool CanConvert(Type typeToConvert) => typeToConvert.IsAbstract;
-
- class ConcreteAbstractSerializerOfType : JsonConverter
- {
- static ConcreteAbstractSerializerOfType()
- {
- if (!typeof(TAbstract).IsAbstract && !typeof(TAbstract).IsInterface)
- throw new NotImplementedException(string.Format("Concrete class {0} is not supported", typeof(TAbstract)));
- }
-
- public override TAbstract? Read(ref System.Text.Json.Utf8JsonReader reader, Type typeToConvert, System.Text.Json.JsonSerializerOptions options) =>
- throw new NotImplementedException();
-
- public override void Write(System.Text.Json.Utf8JsonWriter writer, TAbstract value, System.Text.Json.JsonSerializerOptions options) =>
- JsonSerializer.Serialize