Linux - Show visible error, if xdelta3/ java doesn't exist, Fixes #18

pull/21/head
Miepee 5 years ago
parent c040b48bb4
commit 61ccb4f1a1

@ -215,40 +215,79 @@ namespace AM2RLauncher
/// <returns><see langword="true"/> if it is installed, <see langword="false"/> if not.</returns> /// <returns><see langword="true"/> if it is installed, <see langword="false"/> if not.</returns>
public static bool IsJavaInstalled() public static bool IsJavaInstalled()
{ {
string process = null;
string arguments = null;
if (currentPlatform.IsWinForms) if (currentPlatform.IsWinForms)
{ {
string process = "cmd.exe", process = "cmd.exe";
arguments = "/C java -version"; arguments = "/C java -version";
ProcessStartInfo javaStart = new ProcessStartInfo(); }
javaStart.FileName = process; else if (currentPlatform.IsGtk)
javaStart.Arguments = arguments; {
javaStart.UseShellExecute = false; process = "java";
javaStart.CreateNoWindow = true; arguments = "-version";
}
ProcessStartInfo javaStart = new ProcessStartInfo();
javaStart.FileName = process;
javaStart.Arguments = arguments;
javaStart.UseShellExecute = false;
javaStart.CreateNoWindow = true;
Process java = new Process();
java.StartInfo = javaStart; Process java = new Process();
//this is primarily for linux, but could be happening on windows as well java.StartInfo = javaStart;
try
{
java.Start();
java.WaitForExit(); //this is primarily for linux, but could be happening on windows as well
} try
catch (System.ComponentModel.Win32Exception) {
{ java.Start();
return false;
}
return java.ExitCode == 0; java.WaitForExit();
} }
else if (currentPlatform.IsGtk) catch (System.ComponentModel.Win32Exception)
{ {
return true; // sorry linux users, either Eto, .net or GTK is dumb. return false;
} }
return false;
return java.ExitCode == 0;
}
/// <summary>
/// Checks if command-line xdelta is installed on non-Windows systems.
/// </summary>
/// <returns><see langword="true"/> if it is installed, <see langword="false"/> if not.</returns>
public static bool CheckIfXdeltaIsInstalled()
{
string process = "xdelta3";
string arguments = "-V";
ProcessStartInfo xdeltaStart = new ProcessStartInfo();
xdeltaStart.FileName = process;
xdeltaStart.Arguments = arguments;
xdeltaStart.UseShellExecute = false;
xdeltaStart.CreateNoWindow = true;
Process xdelta = new Process();
xdelta.StartInfo = xdeltaStart;
try
{
xdelta.Start();
xdelta.WaitForExit();
}
catch (System.ComponentModel.Win32Exception)
{
return false;
}
return xdelta.ExitCode == 0;
} }
/// <summary> /// <summary>

@ -251,6 +251,19 @@ namespace AM2RLauncher
{ {
log.Info("Installing profile " + profile.Name + "..."); log.Info("Installing profile " + profile.Name + "...");
// check if xdelta is installed on linux, by searching all folders in PATH
if (Platform.IsGtk && !CrossPlatformOperations.CheckIfXdeltaIsInstalled())
{
Application.Instance.Invoke(new Action(() =>
{
MessageBox.Show(Language.Text.XdeltaNotFound, Language.Text.WarningWindowTitle, MessageBoxButtons.OK);
}));
SetPlayButtonState(UpdateState.Install);
UpdateStateMachine();
log.Error("Xdelta not found. Aborting installing a profile...");
return;
}
string profilesHomePath = CrossPlatformOperations.CURRENTPATH + "/Profiles"; string profilesHomePath = CrossPlatformOperations.CURRENTPATH + "/Profiles";
string profilePath = profilesHomePath + "/" + profile.Name; string profilePath = profilesHomePath + "/" + profile.Name;
@ -420,13 +433,32 @@ namespace AM2RLauncher
// Check for java, exit safely with a warning if not found! // Check for java, exit safely with a warning if not found!
if (!CrossPlatformOperations.IsJavaInstalled()) if (!CrossPlatformOperations.IsJavaInstalled())
{ {
MessageBox.Show(Language.Text.JavaNotFound, Language.Text.WarningWindowTitle, MessageBoxButtons.OK); //message box show needs to be done on main thread
Application.Instance.Invoke(new Action(() =>
{
MessageBox.Show(Language.Text.JavaNotFound, Language.Text.WarningWindowTitle, MessageBoxButtons.OK);
}));
SetApkButtonState(ApkButtonState.Create); SetApkButtonState(ApkButtonState.Create);
UpdateStateMachine(); UpdateStateMachine();
log.Error("Java not found! Aborting Android APK creation."); log.Error("Java not found! Aborting Android APK creation.");
return; return;
} }
// check if xdelta is installed on linux, by searching all folders in PATH
if (Platform.IsGtk && !CrossPlatformOperations.CheckIfXdeltaIsInstalled())
{
//message box show needs to be done on main thread
Application.Instance.Invoke(new Action(() =>
{
MessageBox.Show(Language.Text.XdeltaNotFound, Language.Text.WarningWindowTitle, MessageBoxButtons.OK);
}));
SetApkButtonState(ApkButtonState.Create);
UpdateStateMachine();
log.Error("Xdelta not found. Aborting Android APK creation...");
return;
}
log.Debug("java installed!"); log.Debug("java installed!");
string proc = "", string proc = "",

Loading…
Cancel
Save