From 7d14681fc960f1ccf4e082044d49d45145078dbb Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Mon, 13 Apr 2026 09:43:40 -0400 Subject: [PATCH] Editorconfig and some manual cleanup --- SabreTools.Data.Models/XDVDFS/Constants.cs | 8 +++++--- SabreTools.Data.Models/XboxISO/Constants.cs | 6 ++++-- SabreTools.Data.Models/XboxISO/XboxISO.cs | 4 ++-- SabreTools.Serialization.Readers/XDVDFS.cs | 2 +- SabreTools.Wrappers/WrapperFactory.cs | 5 ++--- SabreTools.Wrappers/XboxISO.Extraction.cs | 8 ++------ SabreTools.Wrappers/XboxISO.Printing.cs | 5 ++--- SabreTools.Wrappers/XboxISO.cs | 12 +++++------- 8 files changed, 23 insertions(+), 27 deletions(-) diff --git a/SabreTools.Data.Models/XDVDFS/Constants.cs b/SabreTools.Data.Models/XDVDFS/Constants.cs index e8dcc903..3e37b883 100644 --- a/SabreTools.Data.Models/XDVDFS/Constants.cs +++ b/SabreTools.Data.Models/XDVDFS/Constants.cs @@ -21,9 +21,11 @@ namespace SabreTools.Data.Models.XDVDFS /// /// Volume Descriptor magic bytes at start of sector 32 /// - public static readonly byte[] VolumeDescriptorMagic = [0x4D, 0x49, 0x43, 0x52, 0x4F, 0x53, 0x4F, 0x46, - 0x54, 0x2A, 0x58, 0x42, 0x4F, 0x58, 0x2A, 0x4D, - 0x45, 0x44, 0x49, 0x41]; + public static readonly byte[] VolumeDescriptorMagic = [ + 0x4D, 0x49, 0x43, 0x52, 0x4F, 0x53, 0x4F, 0x46, + 0x54, 0x2A, 0x58, 0x42, 0x4F, 0x58, 0x2A, 0x4D, + 0x45, 0x44, 0x49, 0x41 + ]; /// /// Volume Descriptor signature at start of sector 32 diff --git a/SabreTools.Data.Models/XboxISO/Constants.cs b/SabreTools.Data.Models/XboxISO/Constants.cs index f99cab0d..6343911f 100644 --- a/SabreTools.Data.Models/XboxISO/Constants.cs +++ b/SabreTools.Data.Models/XboxISO/Constants.cs @@ -11,8 +11,10 @@ namespace SabreTools.Data.Models.XboxISO /// 6/7 = XGD3 /// /// - public static readonly long[] RedumpIsoLengths = [0x1D26A8000, 0x1D3301800, 0x1D2FEF800, 0x1D3082000, - 0x1D3390000, 0x1D31A0000, 0x208E05800, 0x208E03800]; + public static readonly long[] RedumpIsoLengths = [ + 0x1D26A8000, 0x1D3301800, 0x1D2FEF800, 0x1D3082000, + 0x1D3390000, 0x1D31A0000, 0x208E05800, 0x208E03800 + ]; /// /// Known XISO offsets into redump ISOs diff --git a/SabreTools.Data.Models/XboxISO/XboxISO.cs b/SabreTools.Data.Models/XboxISO/XboxISO.cs index 3c7505b0..366deb6c 100644 --- a/SabreTools.Data.Models/XboxISO/XboxISO.cs +++ b/SabreTools.Data.Models/XboxISO/XboxISO.cs @@ -9,7 +9,7 @@ namespace SabreTools.Data.Models.XboxISO /// /// ISO9660 Video parititon, split across start and end of Disc Image /// - public SabreTools.Data.Models.ISO9660.Volume VideoPartition { get; set; } = new(); + public ISO9660.Volume VideoPartition { get; set; } = new(); /// /// XGD type present in game partition @@ -24,6 +24,6 @@ namespace SabreTools.Data.Models.XboxISO /// /// XDVDFS Game partition, present in middle of Disc Image /// - public SabreTools.Data.Models.XDVDFS.Volume GamePartition { get; set; } = new(); + public XDVDFS.Volume GamePartition { get; set; } = new(); } } diff --git a/SabreTools.Serialization.Readers/XDVDFS.cs b/SabreTools.Serialization.Readers/XDVDFS.cs index b13681bb..68875df2 100644 --- a/SabreTools.Serialization.Readers/XDVDFS.cs +++ b/SabreTools.Serialization.Readers/XDVDFS.cs @@ -198,7 +198,7 @@ namespace SabreTools.Serialization.Readers data.SeekIfPossible(initialOffset + (((long)offset) * Constants.SectorSize), SeekOrigin.Begin); long curPosition; - while (size > data.Position - (initialOffset + ((long)offset) * Constants.SectorSize)) + while (size > data.Position - (initialOffset + (((long)offset) * Constants.SectorSize))) { curPosition = data.Position; var dr = ParseDirectoryRecord(data); diff --git a/SabreTools.Wrappers/WrapperFactory.cs b/SabreTools.Wrappers/WrapperFactory.cs index 4caa043e..2ffa5530 100644 --- a/SabreTools.Wrappers/WrapperFactory.cs +++ b/SabreTools.Wrappers/WrapperFactory.cs @@ -89,7 +89,6 @@ namespace SabreTools.Wrappers /// /// Stream data to parse /// IWrapper representing the disc image, null on error - /// TODO: Hook this up in place of ISO in CreateWrapper public static IWrapper? CreateDiscImageWrapper(Stream? stream) { // If we have no stream @@ -101,7 +100,7 @@ namespace SabreTools.Wrappers // Try to get an Xbox ISO wrapper first var xboxWrapper = XboxISO.Create(stream); - if (xboxWrapper is not null && xboxWrapper is XboxISO xboxISO) + if (xboxWrapper is not null) return xboxWrapper; // Reset position in stream @@ -109,7 +108,7 @@ namespace SabreTools.Wrappers // Fallback to standard ISO9660 wrapper var isoWrapper = ISO9660.Create(stream); - if (isoWrapper is null || isoWrapper is not ISO9660 iso) + if (isoWrapper is null) return null; return isoWrapper; diff --git a/SabreTools.Wrappers/XboxISO.Extraction.cs b/SabreTools.Wrappers/XboxISO.Extraction.cs index dffe7854..cd9b4b2b 100644 --- a/SabreTools.Wrappers/XboxISO.Extraction.cs +++ b/SabreTools.Wrappers/XboxISO.Extraction.cs @@ -1,7 +1,3 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Text; using SabreTools.Data.Models.XboxISO; namespace SabreTools.Wrappers @@ -14,11 +10,11 @@ namespace SabreTools.Wrappers long initialOffset = _dataSource.Position; // Extract all files from the video partition - var videoWrapper = new SabreTools.Wrappers.ISO9660(VideoPartition, _dataSource, initialOffset, _dataSource.Length); + var videoWrapper = new ISO9660(VideoPartition, _dataSource, initialOffset, _dataSource.Length); bool success = videoWrapper?.Extract(outputDirectory, includeDebug) ?? false; // Extract all files from the game partition - var gameWrapper = new SabreTools.Wrappers.XDVDFS(GamePartition, _dataSource, initialOffset + Constants.XisoOffsets[XGDType], Constants.XisoLengths[XGDType]); + var gameWrapper = new XDVDFS(GamePartition, _dataSource, initialOffset + Constants.XisoOffsets[XGDType], Constants.XisoLengths[XGDType]); success |= gameWrapper?.Extract(outputDirectory, includeDebug) ?? false; return success; diff --git a/SabreTools.Wrappers/XboxISO.Printing.cs b/SabreTools.Wrappers/XboxISO.Printing.cs index 638ee32b..b911fbee 100644 --- a/SabreTools.Wrappers/XboxISO.Printing.cs +++ b/SabreTools.Wrappers/XboxISO.Printing.cs @@ -1,4 +1,3 @@ -using System; using System.Text; using SabreTools.Data.Models.XboxISO; using SabreTools.Text.Extensions; @@ -36,12 +35,12 @@ namespace SabreTools.Wrappers long initialOffset = _dataSource.Position; // Print all information of video partition model - var videoWrapper = new SabreTools.Wrappers.ISO9660(VideoPartition, _dataSource, initialOffset, _dataSource.Length); + var videoWrapper = new ISO9660(VideoPartition, _dataSource, initialOffset, _dataSource.Length); if (videoWrapper is not null) videoWrapper.PrintInformation(builder); // Print all information of game partition model - var gameWrapper = new SabreTools.Wrappers.XDVDFS(GamePartition, _dataSource, initialOffset + Constants.XisoOffsets[XGDType], Constants.XisoLengths[XGDType]); + var gameWrapper = new XDVDFS(GamePartition, _dataSource, initialOffset + Constants.XisoOffsets[XGDType], Constants.XisoLengths[XGDType]); if (gameWrapper is not null) gameWrapper.PrintInformation(builder); } diff --git a/SabreTools.Wrappers/XboxISO.cs b/SabreTools.Wrappers/XboxISO.cs index 638f0783..065ee5f2 100644 --- a/SabreTools.Wrappers/XboxISO.cs +++ b/SabreTools.Wrappers/XboxISO.cs @@ -1,8 +1,6 @@ using System; -using System.Collections.Generic; using System.IO; using SabreTools.Data.Models.XboxISO; -using SabreTools.IO; using SabreTools.IO.Extensions; using SabreTools.Matching; using SabreTools.Numerics.Extensions; @@ -21,13 +19,13 @@ namespace SabreTools.Wrappers #region Extension Properties /// - public SabreTools.Data.Models.ISO9660.Volume VideoPartition => Model.VideoPartition; + public Data.Models.ISO9660.Volume VideoPartition => Model.VideoPartition; /// public int XGDType => Model.XGDType; /// - public SabreTools.Data.Models.XDVDFS.Volume GamePartition => Model.GamePartition; + public Data.Models.XDVDFS.Volume GamePartition => Model.GamePartition; #endregion @@ -94,12 +92,12 @@ namespace SabreTools.Wrappers // Create new model to fill in var model = new DiscImage(); - + // Try to detect XDVDFS partition int redumpType = Array.IndexOf(Constants.RedumpIsoLengths, data.Length); if (redumpType < 0) return null; - + // Determine location/size of game partition based on total ISO size model.XGDType = redumpType switch { @@ -115,7 +113,7 @@ namespace SabreTools.Wrappers return null; // Verify that XDVDFS game parition exists - long magicOffset = Constants.XisoOffsets[model.XGDType] + Data.Models.XDVDFS.Constants.SectorSize * Data.Models.XDVDFS.Constants.ReservedSectors; + long magicOffset = Constants.XisoOffsets[model.XGDType] + (Data.Models.XDVDFS.Constants.SectorSize * Data.Models.XDVDFS.Constants.ReservedSectors); data.SeekIfPossible(currentOffset + magicOffset, SeekOrigin.Begin); var magic = data.ReadBytes(20); if (magic is null)