From 955fc4b8a072223a534134dd61fa64fc944f8ba1 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Tue, 21 May 2024 13:14:15 -0400 Subject: [PATCH] Simplify access within processors --- CHANGELIST.md | 1 + MPF.Core/Processors/Aaru.cs | 12 ++++---- MPF.Core/Processors/BaseProcessor.cs | 4 +-- MPF.Core/Processors/CleanRip.cs | 6 ++-- MPF.Core/Processors/DiscImageCreator.cs | 36 ++++++++++++------------ MPF.Core/Processors/PS3CFW.cs | 6 ++-- MPF.Core/Processors/Redumper.cs | 16 +++++------ MPF.Core/Processors/UmdImageCreator.cs | 6 ++-- MPF.Core/Processors/XboxBackupCreator.cs | 12 ++++---- 9 files changed, 50 insertions(+), 49 deletions(-) diff --git a/CHANGELIST.md b/CHANGELIST.md index 7c476bcb..7a732d43 100644 --- a/CHANGELIST.md +++ b/CHANGELIST.md @@ -5,6 +5,7 @@ - Seal XBC processor - Migrate processor functionality - Remove now-unneeded parameters classes +- Simplify access within processors ### 3.1.9a (2024-05-21) diff --git a/MPF.Core/Processors/Aaru.cs b/MPF.Core/Processors/Aaru.cs index c6f5dfde..d40c508b 100644 --- a/MPF.Core/Processors/Aaru.cs +++ b/MPF.Core/Processors/Aaru.cs @@ -32,7 +32,7 @@ namespace MPF.Core.Processors public override (bool, List) CheckAllOutputFilesExist(string basePath, bool preCheck) { var missingFiles = new List(); - switch (this.Type) + switch (Type) { case MediaType.CDROM: if (!File.Exists($"{basePath}_logs.zip") || !preCheck) @@ -124,7 +124,7 @@ namespace MPF.Core.Processors // Fill in the hash data info.TracksAndWriteOffsets!.ClrMameProData = InfoTool.GenerateDatfile(datafile); - switch (this.Type) + switch (Type) { // TODO: Can this do GD-ROM? case MediaType.CDROM: @@ -164,9 +164,9 @@ namespace MPF.Core.Processors // Deal with the layerbreak string? layerbreak = null; - if (this.Type == MediaType.DVD) + if (Type == MediaType.DVD) layerbreak = GetLayerbreak(sidecar) ?? string.Empty; - else if (this.Type == MediaType.BluRay) + else if (Type == MediaType.BluRay) layerbreak = info.SizeAndChecksums!.Size > 25_025_314_816 ? "25025314816" : null; // If we have a single-layer disc @@ -186,7 +186,7 @@ namespace MPF.Core.Processors break; } - switch (this.System) + switch (System) { // TODO: Can we get SecuROM data? // TODO: Can we get SS version/ranges? @@ -314,7 +314,7 @@ namespace MPF.Core.Processors public override List GetLogFilePaths(string basePath) { var logFiles = new List(); - switch (this.Type) + switch (Type) { case MediaType.CDROM: if (File.Exists($"{basePath}.cicm.xml")) diff --git a/MPF.Core/Processors/BaseProcessor.cs b/MPF.Core/Processors/BaseProcessor.cs index 0193b717..82e59e98 100644 --- a/MPF.Core/Processors/BaseProcessor.cs +++ b/MPF.Core/Processors/BaseProcessor.cs @@ -36,8 +36,8 @@ namespace MPF.Core.Processors /// MediaType value to use public BaseProcessor(RedumpSystem? system, MediaType? type) { - this.System = system; - this.Type = type; + System = system; + Type = type; } #region Abstract Methods diff --git a/MPF.Core/Processors/CleanRip.cs b/MPF.Core/Processors/CleanRip.cs index 401ebfd9..2f0c1b53 100644 --- a/MPF.Core/Processors/CleanRip.cs +++ b/MPF.Core/Processors/CleanRip.cs @@ -24,7 +24,7 @@ namespace MPF.Core.Processors public override (bool, List) CheckAllOutputFilesExist(string basePath, bool preCheck) { var missingFiles = new List(); - switch (this.Type) + switch (Type) { case MediaType.DVD: // Only added here to help users; not strictly correct case MediaType.NintendoGameCubeGameDisc: @@ -75,7 +75,7 @@ namespace MPF.Core.Processors } // Extract info based generically on MediaType - switch (this.Type) + switch (Type) { case MediaType.DVD: // Only added here to help users; not strictly correct case MediaType.NintendoGameCubeGameDisc: @@ -110,7 +110,7 @@ namespace MPF.Core.Processors public override List GetLogFilePaths(string basePath) { var logFiles = new List(); - switch (this.Type) + switch (Type) { case MediaType.DVD: // Only added here to help users; not strictly correct case MediaType.NintendoGameCubeGameDisc: diff --git a/MPF.Core/Processors/DiscImageCreator.cs b/MPF.Core/Processors/DiscImageCreator.cs index 0c54a3b7..af833f69 100644 --- a/MPF.Core/Processors/DiscImageCreator.cs +++ b/MPF.Core/Processors/DiscImageCreator.cs @@ -72,7 +72,7 @@ namespace MPF.Core.Processors */ var missingFiles = new List(); - switch (this.Type) + switch (Type) { case MediaType.CDROM: case MediaType.GDROM: @@ -82,7 +82,7 @@ namespace MPF.Core.Processors missingFiles.Add($"{basePath}.img"); // Audio-only discs don't output these files - if (!this.System.IsAudio()) + if (!System.IsAudio()) { if (!File.Exists($"{basePath}.scm") && !File.Exists($"{basePath}.scmtmp")) missingFiles.Add($"{basePath}.scm"); @@ -91,7 +91,7 @@ namespace MPF.Core.Processors if (!File.Exists($"{basePath}_logs.zip") || !preCheck) { // GD-ROM and GD-R don't output this for the HD area - if (this.Type != MediaType.GDROM) + if (Type != MediaType.GDROM) { if (!File.Exists($"{basePath}.ccd")) missingFiles.Add($"{basePath}.ccd"); @@ -121,7 +121,7 @@ namespace MPF.Core.Processors missingFiles.Add($"{basePath}_volDesc.txt"); // Audio-only discs don't output these files - if (!this.System.IsAudio()) + if (!System.IsAudio()) { if (!File.Exists($"{basePath}.img_EdcEcc.txt") && !File.Exists($"{basePath}.img_EccEdc.txt")) missingFiles.Add($"{basePath}.img_EdcEcc.txt"); @@ -263,14 +263,14 @@ namespace MPF.Core.Processors VolumeLabels = volLabels; // Extract info based generically on MediaType - switch (this.Type) + switch (Type) { case MediaType.CDROM: case MediaType.GDROM: // TODO: Verify GD-ROM outputs this info.Extras!.PVD = GetPVD($"{basePath}_mainInfo.txt") ?? "Disc has no PVD"; // Audio-only discs will fail if there are any C2 errors, so they would never get here - if (this.System.IsAudio()) + if (System.IsAudio()) { info.CommonDiscInfo!.ErrorsCount = "0"; } @@ -314,12 +314,12 @@ namespace MPF.Core.Processors } // Deal with the layerbreaks - if (this.Type == MediaType.DVD) + if (Type == MediaType.DVD) { string layerbreak = GetLayerbreak($"{basePath}_disc.txt", System.IsXGD()) ?? string.Empty; info.SizeAndChecksums!.Layerbreak = !string.IsNullOrEmpty(layerbreak) ? Int64.Parse(layerbreak) : default; } - else if (this.Type == MediaType.BluRay) + else if (Type == MediaType.BluRay) { var di = InfoTool.GetDiscInformation($"{basePath}_PIC.bin"); info.SizeAndChecksums!.PICIdentifier = InfoTool.GetPICIdentifier(di); @@ -341,10 +341,10 @@ namespace MPF.Core.Processors info.Extras!.PVD = GetPVD($"{basePath}_mainInfo.txt") ?? string.Empty; // Bluray-specific options - if (this.Type == MediaType.BluRay) + if (Type == MediaType.BluRay) { int trimLength = -1; - switch (this.System) + switch (System) { case RedumpSystem.MicrosoftXboxOne: case RedumpSystem.MicrosoftXboxSeriesXS: @@ -367,7 +367,7 @@ namespace MPF.Core.Processors } // Extract info based specifically on RedumpSystem - switch (this.System) + switch (System) { case RedumpSystem.AppleMacintosh: case RedumpSystem.EnhancedCD: @@ -505,7 +505,7 @@ namespace MPF.Core.Processors break; case RedumpSystem.NamcoSegaNintendoTriforce: - if (this.Type == MediaType.CDROM) + if (Type == MediaType.CDROM) { info.Extras!.Header = GetSegaHeader($"{basePath}_mainInfo.txt") ?? string.Empty; @@ -541,7 +541,7 @@ namespace MPF.Core.Processors break; case RedumpSystem.SegaChihiro: - if (this.Type == MediaType.CDROM) + if (Type == MediaType.CDROM) { info.Extras!.Header = GetSegaHeader($"{basePath}_mainInfo.txt") ?? string.Empty; @@ -561,7 +561,7 @@ namespace MPF.Core.Processors break; case RedumpSystem.SegaDreamcast: - if (this.Type == MediaType.CDROM) + if (Type == MediaType.CDROM) { info.Extras!.Header = GetSegaHeader($"{basePath}_mainInfo.txt") ?? string.Empty; @@ -581,7 +581,7 @@ namespace MPF.Core.Processors break; case RedumpSystem.SegaNaomi: - if (this.Type == MediaType.CDROM) + if (Type == MediaType.CDROM) { info.Extras!.Header = GetSegaHeader($"{basePath}_mainInfo.txt") ?? string.Empty; @@ -601,7 +601,7 @@ namespace MPF.Core.Processors break; case RedumpSystem.SegaNaomi2: - if (this.Type == MediaType.CDROM) + if (Type == MediaType.CDROM) { info.Extras!.Header = GetSegaHeader($"{basePath}_mainInfo.txt") ?? string.Empty; @@ -753,7 +753,7 @@ namespace MPF.Core.Processors public override List GetDeleteableFilePaths(string basePath) { var deleteableFiles = new List(); - switch (this.Type) + switch (Type) { case MediaType.CDROM: case MediaType.GDROM: @@ -805,7 +805,7 @@ namespace MPF.Core.Processors (var cmdPath, _) = GetCommandFilePathAndVersion(basePath); var logFiles = new List(); - switch (this.Type) + switch (Type) { case MediaType.CDROM: case MediaType.GDROM: diff --git a/MPF.Core/Processors/PS3CFW.cs b/MPF.Core/Processors/PS3CFW.cs index 983974a2..b4ab8dd5 100644 --- a/MPF.Core/Processors/PS3CFW.cs +++ b/MPF.Core/Processors/PS3CFW.cs @@ -24,7 +24,7 @@ namespace MPF.Core.Processors { var missingFiles = new List(); - if (this.Type != MediaType.BluRay || this.System != RedumpSystem.SonyPlayStation3) + if (Type != MediaType.BluRay || System != RedumpSystem.SonyPlayStation3) { missingFiles.Add("Media and system combination not supported for PS3 CFW"); } @@ -123,10 +123,10 @@ namespace MPF.Core.Processors var logFiles = new List(); string? getKeyBasePath = GetCFWBasePath(basePath); - if (this.System != RedumpSystem.SonyPlayStation3) + if (System != RedumpSystem.SonyPlayStation3) return logFiles; - switch (this.Type) + switch (Type) { case MediaType.BluRay: if (File.Exists($"{getKeyBasePath}.getkey.log")) diff --git a/MPF.Core/Processors/Redumper.cs b/MPF.Core/Processors/Redumper.cs index 8054ec74..7c03661a 100644 --- a/MPF.Core/Processors/Redumper.cs +++ b/MPF.Core/Processors/Redumper.cs @@ -26,7 +26,7 @@ namespace MPF.Core.Processors { var missingFiles = new List(); - switch (this.Type) + switch (Type) { case MediaType.CDROM: if (!File.Exists($"{basePath}.cue")) @@ -152,7 +152,7 @@ namespace MPF.Core.Processors if (GetVolumeLabels($"{basePath}.log", out var volLabels)) VolumeLabels = volLabels; - switch (this.Type) + switch (Type) { case MediaType.CDROM: info.Extras!.PVD = GetPVD($"{basePath}.log") ?? "Disc has no PVD"; @@ -177,14 +177,14 @@ namespace MPF.Core.Processors info.CommonDiscInfo.CommentsSpecialFields![SiteCode.Multisession] = cdMultiSessionInfo; // Attempt to get the universal hash, if it's an audio disc - if (this.System.IsAudio()) + if (System.IsAudio()) { string universalHash = GetUniversalHash($"{basePath}.log") ?? string.Empty; info.CommonDiscInfo.CommentsSpecialFields![SiteCode.UniversalHash] = universalHash; } // Attempt to get the non-zero data start, if it's an audio disc - if (this.System.IsAudio()) + if (System.IsAudio()) { string ringNonZeroDataStart = GetRingNonZeroDataStart($"{basePath}.log") ?? string.Empty; info.CommonDiscInfo.CommentsSpecialFields![SiteCode.RingNonZeroDataStart] = ringNonZeroDataStart; @@ -216,10 +216,10 @@ namespace MPF.Core.Processors } // Bluray-specific options - if (this.Type == MediaType.BluRay) + if (Type == MediaType.BluRay) { int trimLength = -1; - switch (this.System) + switch (System) { case RedumpSystem.MicrosoftXboxOne: case RedumpSystem.MicrosoftXboxSeriesXS: @@ -249,7 +249,7 @@ namespace MPF.Core.Processors break; } - switch (this.System) + switch (System) { case RedumpSystem.AppleMacintosh: case RedumpSystem.EnhancedCD: @@ -502,7 +502,7 @@ namespace MPF.Core.Processors { var logFiles = new List(); - switch (this.Type) + switch (Type) { case MediaType.CDROM: if (File.Exists($"{basePath}.cdtext")) diff --git a/MPF.Core/Processors/UmdImageCreator.cs b/MPF.Core/Processors/UmdImageCreator.cs index 9d210387..8da4ff81 100644 --- a/MPF.Core/Processors/UmdImageCreator.cs +++ b/MPF.Core/Processors/UmdImageCreator.cs @@ -24,7 +24,7 @@ namespace MPF.Core.Processors public override (bool, List) CheckAllOutputFilesExist(string basePath, bool preCheck) { var missingFiles = new List(); - switch (this.Type) + switch (Type) { case MediaType.UMD: if (!File.Exists($"{basePath}_logs.zip") || !preCheck) @@ -64,7 +64,7 @@ namespace MPF.Core.Processors VolumeLabels = volLabels; // Extract info based generically on MediaType - switch (this.Type) + switch (Type) { case MediaType.UMD: info.Extras!.PVD = GetPVD(basePath + "_mainInfo.txt") ?? string.Empty; @@ -124,7 +124,7 @@ namespace MPF.Core.Processors public override List GetLogFilePaths(string basePath) { var logFiles = new List(); - switch (this.Type) + switch (Type) { case MediaType.UMD: if (File.Exists($"{basePath}_disc.txt")) diff --git a/MPF.Core/Processors/XboxBackupCreator.cs b/MPF.Core/Processors/XboxBackupCreator.cs index 139081ce..6d6b8ae9 100644 --- a/MPF.Core/Processors/XboxBackupCreator.cs +++ b/MPF.Core/Processors/XboxBackupCreator.cs @@ -24,7 +24,7 @@ namespace MPF.Core.Processors public override (bool, List) CheckAllOutputFilesExist(string basePath, bool preCheck) { var missingFiles = new List(); - switch (this.Type) + switch (Type) { case MediaType.DVD: if (!File.Exists($"{basePath}_logs.zip") || !preCheck) @@ -79,7 +79,7 @@ namespace MPF.Core.Processors info.CommonDiscInfo!.ErrorsCount = readErrors == -1 ? "Error retrieving error count" : readErrors.ToString(); // Extract info based generically on MediaType - switch (this.Type) + switch (Type) { case MediaType.DVD: @@ -105,7 +105,7 @@ namespace MPF.Core.Processors info.SizeAndChecksums.SHA1 = sha1; } - switch (this.System) + switch (System) { case RedumpSystem.MicrosoftXbox: @@ -204,7 +204,7 @@ namespace MPF.Core.Processors { var logFiles = new List(); string baseDir = Path.GetDirectoryName(basePath) + Path.DirectorySeparatorChar; - switch (this.Type) + switch (Type) { case MediaType.DVD: string? logPath = GetLogName(baseDir); @@ -459,7 +459,7 @@ namespace MPF.Core.Processors bool success = long.TryParse(errorCount, out readErrors); // Original Xbox should have 65536 read errors when dumping with XBC - if (this.System == RedumpSystem.MicrosoftXbox) + if (System == RedumpSystem.MicrosoftXbox) { if (readErrors == 65536) readErrors = 0; @@ -492,7 +492,7 @@ namespace MPF.Core.Processors if (string.IsNullOrEmpty(log) || !File.Exists(log)) return null; - if (this.System == RedumpSystem.MicrosoftXbox) + if (System == RedumpSystem.MicrosoftXbox) return null; // Example: