mirror of
https://github.com/SabreTools/MPF.git
synced 2026-07-02 17:24:48 +00:00
Ensure the executable exists before trying to run it
This commit is contained in:
@@ -164,11 +164,28 @@ 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()
|
||||
|
||||
@@ -475,6 +475,13 @@ namespace MPF.Utilities
|
||||
if (!result)
|
||||
return result;
|
||||
|
||||
// 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);
|
||||
|
||||
@@ -646,6 +646,13 @@ namespace MPF.Windows
|
||||
ShowDiscInformationWindow
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
ViewModels.LoggerViewModel.VerboseLogLn(result.Message);
|
||||
StatusLabel.Content = "Execution failed!";
|
||||
StartStopButton.Content = Interface.StartDumping;
|
||||
CopyProtectScanButton.IsEnabled = true;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user