From 22a6b77d27e94cf8ced4f6c752ea9cd7e6cebc79 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Thu, 22 Aug 2024 14:22:37 -0400 Subject: [PATCH] Hook up GetOutputFiles in debug way --- CHANGELIST.md | 1 + MPF.Processors/Aaru.cs | 5 +++ MPF.Processors/BaseProcessor.cs | 49 +++++++++++++++++++------ MPF.Processors/CleanRip.cs | 5 +++ MPF.Processors/DiscImageCreator.cs | 56 +++-------------------------- MPF.Processors/PS3CFW.cs | 5 +++ MPF.Processors/Redumper.cs | 18 +++------- MPF.Processors/UmdImageCreator.cs | 5 +++ MPF.Processors/XboxBackupCreator.cs | 5 +++ 9 files changed, 74 insertions(+), 75 deletions(-) diff --git a/CHANGELIST.md b/CHANGELIST.md index cd0ae0bd..e7da5ab3 100644 --- a/CHANGELIST.md +++ b/CHANGELIST.md @@ -34,6 +34,7 @@ - Create currently-unused helper class - Make helper class more robust - Add unused GetOutputFiles method +- Hook up GetOutputFiles in debug way ### 3.2.1 (2024-08-05) diff --git a/MPF.Processors/Aaru.cs b/MPF.Processors/Aaru.cs index c0bb8d58..c2732bc6 100644 --- a/MPF.Processors/Aaru.cs +++ b/MPF.Processors/Aaru.cs @@ -34,6 +34,11 @@ namespace MPF.Processors string baseFilename = Path.GetFileName(basePath); string baseDirectory = Path.GetDirectoryName(basePath) ?? string.Empty; + // Get the list of output files + var outputFiles = GetOutputFiles(baseFilename); + if (outputFiles.Count == 0) + return (false, ["Media and system combination not supported for Aaru"]); + var missingFiles = new List(); switch (Type) { diff --git a/MPF.Processors/BaseProcessor.cs b/MPF.Processors/BaseProcessor.cs index c27eec57..ccdda6df 100644 --- a/MPF.Processors/BaseProcessor.cs +++ b/MPF.Processors/BaseProcessor.cs @@ -83,17 +83,6 @@ namespace MPF.Processors #endregion - #region Virtual Methods - - /// - /// Generate a list of all deleteable files generated - /// - /// Base filename and path to use for checking - /// List of all deleteable file paths, empty otherwise - public virtual List GetDeleteableFilePaths(string basePath) => []; - - #endregion - #region Shared Methods /// @@ -254,6 +243,44 @@ namespace MPF.Processors return CheckAllOutputFilesExist(basePath, preCheck); } + /// + /// Generate a list of all deleteable files generated + /// + /// Base filename and path to use for checking + /// List of all deleteable file paths, empty otherwise + public List GetDeleteableFilePaths(string basePath) + { + // Get the base filename and directory from the base path + string baseFilename = Path.GetFileName(basePath); + string baseDirectory = Path.GetDirectoryName(basePath) ?? string.Empty; + + // Get the list of output files + var outputFiles = GetOutputFiles(baseFilename); + if (outputFiles.Count == 0) + return []; + + // Return only files that exist + var deleteableFiles = new List(); + foreach (var outputFile in outputFiles) + { + // Skip undeleteable files + if (!outputFile.IsDeleteable) + continue; + + // Skip non-existent files + foreach (string filename in outputFile.Filenames) + { + string outputFilePath = Path.Combine(baseDirectory, filename); + if (!File.Exists(outputFilePath)) + continue; + + deleteableFiles.Add(outputFilePath); + } + } + + return deleteableFiles; + } + /// /// Get the hex contents of the PIC file /// diff --git a/MPF.Processors/CleanRip.cs b/MPF.Processors/CleanRip.cs index f7580931..0080c3ea 100644 --- a/MPF.Processors/CleanRip.cs +++ b/MPF.Processors/CleanRip.cs @@ -26,6 +26,11 @@ namespace MPF.Processors string baseFilename = Path.GetFileName(basePath); string baseDirectory = Path.GetDirectoryName(basePath) ?? string.Empty; + // Get the list of output files + var outputFiles = GetOutputFiles(baseFilename); + if (outputFiles.Count == 0) + return (false, ["Media and system combination not supported for CleanRip"]); + var missingFiles = new List(); switch (Type) { diff --git a/MPF.Processors/DiscImageCreator.cs b/MPF.Processors/DiscImageCreator.cs index 2763717a..e5b9296e 100644 --- a/MPF.Processors/DiscImageCreator.cs +++ b/MPF.Processors/DiscImageCreator.cs @@ -74,6 +74,11 @@ namespace MPF.Processors string baseFilename = Path.GetFileName(basePath); string baseDirectory = Path.GetDirectoryName(basePath) ?? string.Empty; + // Get the list of output files + var outputFiles = GetOutputFiles(baseFilename); + if (outputFiles.Count == 0) + return (false, ["Media and system combination not supported for DiscImageCreator"]); + var missingFiles = new List(); switch (Type) { @@ -700,57 +705,6 @@ namespace MPF.Processors } } - /// - public override List GetDeleteableFilePaths(string basePath) - { - var deleteableFiles = new List(); - switch (Type) - { - // TODO: Handle (Pregap) files -- need examples - case MediaType.CDROM: - case MediaType.GDROM: - if (File.Exists($"{basePath}.img")) - deleteableFiles.Add($"{basePath}.img"); - if (File.Exists($"{basePath} (Track 0).img")) - deleteableFiles.Add($"{basePath} (Track 0).img"); - if (File.Exists($"{basePath} (Track 00).img")) - deleteableFiles.Add($"{basePath} (Track 00).img"); - if (File.Exists($"{basePath} (Track 1)(-LBA).img")) - deleteableFiles.Add($"{basePath} (Track 1)(-LBA).img"); - if (File.Exists($"{basePath} (Track 01)(-LBA).img")) - deleteableFiles.Add($"{basePath} (Track 01)(-LBA).img"); - if (File.Exists($"{basePath} (Track AA).img")) - deleteableFiles.Add($"{basePath} (Track AA).img"); - - if (File.Exists($"{basePath}.scm")) - deleteableFiles.Add($"{basePath}.scm"); - if (File.Exists($"{basePath} (Track 0).scm")) - deleteableFiles.Add($"{basePath} (Track 0).scm"); - if (File.Exists($"{basePath} (Track 00).scm")) - deleteableFiles.Add($"{basePath} (Track 00).scm"); - if (File.Exists($"{basePath} (Track 1)(-LBA).scm")) - deleteableFiles.Add($"{basePath} (Track 1)(-LBA).scm"); - if (File.Exists($"{basePath} (Track 01)(-LBA).scm")) - deleteableFiles.Add($"{basePath} (Track 01)(-LBA).scm"); - if (File.Exists($"{basePath} (Track AA).scm")) - deleteableFiles.Add($"{basePath} (Track AA).scm"); - - break; - - case MediaType.DVD: - case MediaType.HDDVD: - case MediaType.BluRay: - case MediaType.NintendoGameCubeGameDisc: - case MediaType.NintendoWiiOpticalDisc: - if (File.Exists($"{basePath}.raw")) - deleteableFiles.Add($"{basePath}.raw"); - - break; - } - - return deleteableFiles; - } - /// public override List GetLogFilePaths(string basePath) { diff --git a/MPF.Processors/PS3CFW.cs b/MPF.Processors/PS3CFW.cs index d1bf4136..c80b7882 100644 --- a/MPF.Processors/PS3CFW.cs +++ b/MPF.Processors/PS3CFW.cs @@ -25,6 +25,11 @@ namespace MPF.Processors string baseFilename = Path.GetFileName(basePath); string baseDirectory = Path.GetDirectoryName(basePath) ?? string.Empty; + // Get the list of output files + var outputFiles = GetOutputFiles(baseFilename); + if (outputFiles.Count == 0) + return (false, ["Media and system combination not supported for PS3 CFW"]); + var missingFiles = new List(); if (Type != MediaType.BluRay || System != RedumpSystem.SonyPlayStation3) diff --git a/MPF.Processors/Redumper.cs b/MPF.Processors/Redumper.cs index f5535795..a14d59cc 100644 --- a/MPF.Processors/Redumper.cs +++ b/MPF.Processors/Redumper.cs @@ -27,6 +27,11 @@ namespace MPF.Processors string baseFilename = Path.GetFileName(basePath); string baseDirectory = Path.GetDirectoryName(basePath) ?? string.Empty; + // Get the list of output files + var outputFiles = GetOutputFiles(baseFilename); + if (outputFiles.Count == 0) + return (false, ["Media and system combination not supported for Redumper"]); + var missingFiles = new List(); switch (Type) @@ -530,19 +535,6 @@ namespace MPF.Processors } } - /// - public override List GetDeleteableFilePaths(string basePath) - { - var deleteableFiles = new List(); - - if (File.Exists($"{basePath}.scram")) - deleteableFiles.Add($"{basePath}.scram"); - if (File.Exists($"{basePath}.scrap")) - deleteableFiles.Add($"{basePath}.scrap"); - - return deleteableFiles; - } - /// public override List GetLogFilePaths(string basePath) { diff --git a/MPF.Processors/UmdImageCreator.cs b/MPF.Processors/UmdImageCreator.cs index 867ef3c6..a5d79657 100644 --- a/MPF.Processors/UmdImageCreator.cs +++ b/MPF.Processors/UmdImageCreator.cs @@ -26,6 +26,11 @@ namespace MPF.Processors string baseFilename = Path.GetFileName(basePath); string baseDirectory = Path.GetDirectoryName(basePath) ?? string.Empty; + // Get the list of output files + var outputFiles = GetOutputFiles(baseFilename); + if (outputFiles.Count == 0) + return (false, ["Media and system combination not supported for UmdImageCreator"]); + var missingFiles = new List(); switch (Type) { diff --git a/MPF.Processors/XboxBackupCreator.cs b/MPF.Processors/XboxBackupCreator.cs index c27793bb..af7eb2c8 100644 --- a/MPF.Processors/XboxBackupCreator.cs +++ b/MPF.Processors/XboxBackupCreator.cs @@ -25,6 +25,11 @@ namespace MPF.Processors string baseFilename = Path.GetFileName(basePath); string baseDirectory = Path.GetDirectoryName(basePath) ?? string.Empty; + // Get the list of output files + var outputFiles = GetOutputFiles(baseFilename); + if (outputFiles.Count == 0) + return (false, ["Media and system combination not supported for XboxBackupCreator"]); + var missingFiles = new List(); switch (Type) {