From e67dd589b503f57fe017c745b8d7af3a29c4fb67 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Fri, 1 May 2020 14:59:29 -0700 Subject: [PATCH] Fix options, add fallbacks, consolidate code --- DICUI.Library/Aaru/Parameters.cs | 18 +++++ DICUI.Library/DD/Parameters.cs | 13 ++++ DICUI.Library/Data/BaseParameters.cs | 9 +++ DICUI.Library/DiscImageCreator/Parameters.cs | 74 ++++++++++++++++++++ DICUI/Windows/MainWindow.xaml.cs | 10 ++- DICUI/Windows/OptionsWindow.xaml.cs | 2 +- 6 files changed, 123 insertions(+), 3 deletions(-) diff --git a/DICUI.Library/Aaru/Parameters.cs b/DICUI.Library/Aaru/Parameters.cs index e3578a3f..68625a09 100644 --- a/DICUI.Library/Aaru/Parameters.cs +++ b/DICUI.Library/Aaru/Parameters.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Text.RegularExpressions; using DICUI.Data; @@ -1348,6 +1349,23 @@ namespace DICUI.Aaru return true; } + /// + /// Validate if all required output files exist + /// + /// Base filename and path to use for checking + /// KnownSystem type representing the media + /// MediaType type representing the media + /// + public override bool CheckAllOutputFilesExist(string basePath, KnownSystem? system, MediaType? type) + { + return File.Exists(basePath + ".cicm.xml") + && File.Exists(basePath + ".aif") + && File.Exists(basePath + ".ibg") + && File.Exists(basePath + ".log") + && File.Exists(basePath + ".mhddlog.bin") + && File.Exists(basePath + ".resume.xml"); + } + /// /// Get the list of commands that use a given flag /// diff --git a/DICUI.Library/DD/Parameters.cs b/DICUI.Library/DD/Parameters.cs index a83f8c85..9cf3aff9 100644 --- a/DICUI.Library/DD/Parameters.cs +++ b/DICUI.Library/DD/Parameters.cs @@ -390,6 +390,19 @@ namespace DICUI.DD return true; } + /// + /// Validate if all required output files exist + /// + /// Base filename and path to use for checking + /// KnownSystem type representing the media + /// MediaType type representing the media + /// + public override bool CheckAllOutputFilesExist(string basePath, KnownSystem? system, MediaType? type) + { + // TODO: Figure out what sort of output files are expected... just `.bin`? + return true; + } + /// /// Get the list of commands that use a given flag /// diff --git a/DICUI.Library/Data/BaseParameters.cs b/DICUI.Library/Data/BaseParameters.cs index 4e9e717d..d0c0d5fe 100644 --- a/DICUI.Library/Data/BaseParameters.cs +++ b/DICUI.Library/Data/BaseParameters.cs @@ -126,6 +126,15 @@ namespace DICUI.Data /// protected abstract bool ValidateAndSetParameters(string parameters); + /// + /// Validate if all required output files exist + /// + /// Base filename and path to use for checking + /// KnownSystem type representing the media + /// MediaType type representing the media + /// + public abstract bool CheckAllOutputFilesExist(string basePath, KnownSystem? system, MediaType? type); + /// /// Returns whether or not the selected item exists /// diff --git a/DICUI.Library/DiscImageCreator/Parameters.cs b/DICUI.Library/DiscImageCreator/Parameters.cs index 1e5a789f..9ca5bca5 100644 --- a/DICUI.Library/DiscImageCreator/Parameters.cs +++ b/DICUI.Library/DiscImageCreator/Parameters.cs @@ -1453,6 +1453,80 @@ namespace DICUI.DiscImageCreator return true; } + /// + /// Validate if all required output files exist + /// + /// Base filename and path to use for checking + /// KnownSystem type representing the media + /// MediaType type representing the media + /// + public override bool CheckAllOutputFilesExist(string basePath, KnownSystem? system, MediaType? type) + { + // Some disc types are audio-only + bool audioOnly = (system == KnownSystem.AtariJaguarCD) + || (system == KnownSystem.AudioCD) + || (system == KnownSystem.SuperAudioCD); + + switch (type) + { + case MediaType.CDROM: + case MediaType.GDROM: // TODO: Verify GD-ROM outputs this + // return File.Exists(combinedBase + ".c2") // Doesn't output on Linux + return File.Exists(basePath + ".ccd") + && File.Exists(basePath + ".cue") + && File.Exists(basePath + ".dat") + && File.Exists(basePath + ".img") + && (audioOnly || File.Exists(basePath + ".img_EdcEcc.txt") || File.Exists(basePath + ".img_EccEdc.txt")) + && (audioOnly || File.Exists(basePath + ".scm")) + && File.Exists(basePath + ".sub") + // && File.Exists(combinedBase + "_c2Error.txt") // Doesn't output on Linux + && File.Exists(basePath + "_cmd.txt") + && File.Exists(basePath + "_disc.txt") + && File.Exists(basePath + "_drive.txt") + && File.Exists(basePath + "_img.cue") + && File.Exists(basePath + "_mainError.txt") + && File.Exists(basePath + "_mainInfo.txt") + && File.Exists(basePath + "_subError.txt") + && File.Exists(basePath + "_subInfo.txt") + // && File.Exists(combinedBase + "_subIntention.txt") // Not guaranteed output + && (File.Exists(basePath + "_subReadable.txt") || File.Exists(basePath + "_sub.txt")) + && File.Exists(basePath + "_volDesc.txt"); + + case MediaType.DVD: + case MediaType.HDDVD: + case MediaType.BluRay: + case MediaType.NintendoGameCubeGameDisc: + case MediaType.NintendoWiiOpticalDisc: + bool dicDump = File.Exists(basePath + ".dat") + && File.Exists(basePath + "_cmd.txt") + && File.Exists(basePath + "_disc.txt") + && File.Exists(basePath + "_drive.txt") + && File.Exists(basePath + "_mainError.txt") + && File.Exists(basePath + "_mainInfo.txt") + && File.Exists(basePath + "_volDesc.txt"); + bool cleanRipDump = File.Exists(basePath + "-dumpinfo.txt") + && File.Exists(basePath + ".bca"); + return dicDump | cleanRipDump; + + case MediaType.FloppyDisk: + case MediaType.HardDisk: + // TODO: Determine what outputs come out from a HDD, SD, etc. + return File.Exists(basePath + ".dat") + && File.Exists(basePath + "_cmd.txt") + && File.Exists(basePath + "_disc.txt"); + + case MediaType.UMD: + return File.Exists(basePath + "_disc.txt") + || File.Exists(basePath + "_mainError.txt") + || File.Exists(basePath + "_mainInfo.txt") + || File.Exists(basePath + "_volDesc.txt"); + + default: + // Non-dumping commands will usually produce no output, so this is irrelevant + return true; + } + } + /// /// Get the list of commands that use a given flag /// diff --git a/DICUI/Windows/MainWindow.xaml.cs b/DICUI/Windows/MainWindow.xaml.cs index 1454e569..f9eceafb 100644 --- a/DICUI/Windows/MainWindow.xaml.cs +++ b/DICUI/Windows/MainWindow.xaml.cs @@ -482,6 +482,12 @@ namespace DICUI.Windows case InternalProgram.DiscImageCreator: env.Parameters.Path = _options.CreatorPath; break; + + // This should never happen, but it needs a fallback. + default: + env.InternalProgram = InternalProgram.DiscImageCreator; + env.Parameters.Path = _options.CreatorPath; + break; } // Disable automatic reprocessing of the textboxes until we're done @@ -502,8 +508,8 @@ namespace DICUI.Windows /// private async void StartDumping() { - if (_env == null) - _env = DetermineEnvironment(); + // One last check to determine environment, just in case + _env = DetermineEnvironment(); // If still in custom parameter mode, check that users meant to continue or not if (EnableParametersCheckBox.IsChecked == true) diff --git a/DICUI/Windows/OptionsWindow.xaml.cs b/DICUI/Windows/OptionsWindow.xaml.cs index c49a172a..9f424ac0 100644 --- a/DICUI/Windows/OptionsWindow.xaml.cs +++ b/DICUI/Windows/OptionsWindow.xaml.cs @@ -43,7 +43,7 @@ namespace DICUI.Windows private string[] PathSettings() { - string[] pathSettings = { "AaruPath", "CreatorPath", "DDPath", "DefaultOutputPath", "SubDumpPath" }; + string[] pathSettings = { "AaruPath", "CreatorPath", /* "DDPath", */ "DefaultOutputPath", "SubDumpPath" }; return pathSettings; }