mirror of
https://github.com/SabreTools/MPF.git
synced 2026-07-02 17:24:48 +00:00
Streamline statuses from trying to execute
This commit is contained in:
@@ -164,28 +164,11 @@ namespace MPF.Data
|
||||
/// <param name="drive">Drive representing the disc to get information from</param>
|
||||
public abstract void GenerateSubmissionInfo(SubmissionInfo submissionInfo, string basePath, Drive drive);
|
||||
|
||||
/// <summary>
|
||||
/// Returns if the related executable exists in the configured path or not
|
||||
/// </summary>
|
||||
/// <returns>True if the executable exists, false otherwise</returns>
|
||||
public bool InternalProgramExists()
|
||||
{
|
||||
// Missing path information means we can't invoke anyway
|
||||
if (string.IsNullOrWhiteSpace(ExecutablePath))
|
||||
return false;
|
||||
|
||||
return File.Exists(ExecutablePath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Run internal program
|
||||
/// </summary>
|
||||
public void ExecuteInternalProgram()
|
||||
{
|
||||
// Invalid path means we shouldn't try to invoke
|
||||
if (!InternalProgramExists())
|
||||
return;
|
||||
|
||||
process = new Process()
|
||||
{
|
||||
StartInfo = new ProcessStartInfo()
|
||||
|
||||
@@ -464,35 +464,21 @@ namespace MPF.Utilities
|
||||
/// <param name="progress">Optional result progress callback</param>
|
||||
public async Task<Result> Run(IProgress<Result> progress = null)
|
||||
{
|
||||
// Check that we have the basics for dumping
|
||||
Result result = IsValidForDump();
|
||||
if (!result)
|
||||
return result;
|
||||
|
||||
// Execute dumping program and external tools, if needed
|
||||
if (Validators.GetSupportStatus(System, Type)
|
||||
&& !result.Message.Contains("not supported") // Completely unsupported media
|
||||
&& !result.Message.Contains("submission info")) // Submission info-only media
|
||||
{
|
||||
// If the environment is invalid, return
|
||||
if (!result)
|
||||
return result;
|
||||
// Execute internal tool
|
||||
progress?.Report(Result.Success($"Executing {this.InternalProgram}... please wait!"));
|
||||
Directory.CreateDirectory(OutputDirectory);
|
||||
await Task.Run(() => Parameters.ExecuteInternalProgram());
|
||||
progress?.Report(Result.Success($"{this.InternalProgram} has finished!"));
|
||||
|
||||
// Check that the internal tool exists
|
||||
if (!Parameters.InternalProgramExists())
|
||||
{
|
||||
progress?.Report(Result.Success($"Could not find executable for {this.InternalProgram}!"));
|
||||
return Result.Failure($"Could not find executable for {this.InternalProgram}!");
|
||||
}
|
||||
|
||||
// Execute internal tool
|
||||
progress?.Report(Result.Success($"Executing {this.InternalProgram}... please wait!"));
|
||||
Directory.CreateDirectory(OutputDirectory);
|
||||
await Task.Run(() => Parameters.ExecuteInternalProgram());
|
||||
progress?.Report(Result.Success($"{this.InternalProgram} has finished!"));
|
||||
|
||||
// Execute additional tools
|
||||
progress?.Report(Result.Success("Running any additional tools... please wait!"));
|
||||
result = await Task.Run(() => ExecuteAdditionalTools());
|
||||
progress?.Report(result);
|
||||
}
|
||||
// Execute additional tools
|
||||
progress?.Report(Result.Success("Running any additional tools... please wait!"));
|
||||
result = await Task.Run(() => ExecuteAdditionalTools());
|
||||
progress?.Report(result);
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -1298,15 +1284,17 @@ namespace MPF.Utilities
|
||||
if (!ParametersValid())
|
||||
return Result.Failure("Error! Current configuration is not supported!");
|
||||
|
||||
// Fix the output paths, just in case
|
||||
FixOutputPaths();
|
||||
|
||||
// Validate that the required program exists
|
||||
if (!File.Exists(Parameters.ExecutablePath))
|
||||
return Result.Failure("Error! Could not find the program!");
|
||||
return Result.Failure($"Error! {Parameters.ExecutablePath} does not exist!");
|
||||
|
||||
// TODO: Ensure output path not the same as input drive OR executable location
|
||||
|
||||
return Result.Success();
|
||||
// Validate that the current configuration is supported
|
||||
return Validators.GetSupportStatus(System, Type);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -979,25 +979,25 @@ namespace MPF.Utilities
|
||||
case MediaType.SDCard:
|
||||
case MediaType.FlashDrive:
|
||||
case MediaType.HDDVD:
|
||||
return Result.Success("{0} ready to dump", type.LongName());
|
||||
return Result.Success($"{type.LongName()} ready to dump");
|
||||
|
||||
// Partially supported types
|
||||
case MediaType.GDROM:
|
||||
case MediaType.NintendoGameCubeGameDisc:
|
||||
case MediaType.NintendoWiiOpticalDisc:
|
||||
return Result.Success("{0} partially supported for dumping", type.LongName());
|
||||
return Result.Success($"{type.LongName()} partially supported for dumping");
|
||||
|
||||
// Special case for other supported tools
|
||||
case MediaType.UMD:
|
||||
return Result.Success("{0} supported for submission info parsing", type.LongName());
|
||||
return Result.Failure($"{type.LongName()} supported for submission info parsing");
|
||||
|
||||
// Specifically unknown type
|
||||
case MediaType.NONE:
|
||||
return Result.Failure("Please select a valid media type");
|
||||
return Result.Failure($"Please select a valid media type");
|
||||
|
||||
// Undumpable but recognized types
|
||||
default:
|
||||
return Result.Failure("{0} media are not supported for dumping", type.LongName());
|
||||
return Result.Failure($"{type.LongName()} media are not supported for dumping");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user