Fix options, add fallbacks, consolidate code

This commit is contained in:
Matt Nadareski
2020-05-01 14:59:29 -07:00
parent 74f491eaaa
commit e67dd589b5
6 changed files with 123 additions and 3 deletions

View File

@@ -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;
}
/// <summary>
/// Validate if all required output files exist
/// </summary>
/// <param name="basePath">Base filename and path to use for checking</param>
/// <param name="system">KnownSystem type representing the media</param>
/// <param name="type">MediaType type representing the media</param>
/// <returns></returns>
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");
}
/// <summary>
/// Get the list of commands that use a given flag
/// </summary>

View File

@@ -390,6 +390,19 @@ namespace DICUI.DD
return true;
}
/// <summary>
/// Validate if all required output files exist
/// </summary>
/// <param name="basePath">Base filename and path to use for checking</param>
/// <param name="system">KnownSystem type representing the media</param>
/// <param name="type">MediaType type representing the media</param>
/// <returns></returns>
public override bool CheckAllOutputFilesExist(string basePath, KnownSystem? system, MediaType? type)
{
// TODO: Figure out what sort of output files are expected... just `.bin`?
return true;
}
/// <summary>
/// Get the list of commands that use a given flag
/// </summary>

View File

@@ -126,6 +126,15 @@ namespace DICUI.Data
/// <returns></returns>
protected abstract bool ValidateAndSetParameters(string parameters);
/// <summary>
/// Validate if all required output files exist
/// </summary>
/// <param name="basePath">Base filename and path to use for checking</param>
/// <param name="system">KnownSystem type representing the media</param>
/// <param name="type">MediaType type representing the media</param>
/// <returns></returns>
public abstract bool CheckAllOutputFilesExist(string basePath, KnownSystem? system, MediaType? type);
/// <summary>
/// Returns whether or not the selected item exists
/// </summary>

View File

@@ -1453,6 +1453,80 @@ namespace DICUI.DiscImageCreator
return true;
}
/// <summary>
/// Validate if all required output files exist
/// </summary>
/// <param name="basePath">Base filename and path to use for checking</param>
/// <param name="system">KnownSystem type representing the media</param>
/// <param name="type">MediaType type representing the media</param>
/// <returns></returns>
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;
}
}
/// <summary>
/// Get the list of commands that use a given flag
/// </summary>

View File

@@ -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
/// </summary>
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)

View File

@@ -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;
}