/// <summary> /// Verifies that SteamCMD is present in the installation. Should be called before running SteamCMD.exe or doing /// anything with SteamCMD. /// </summary> private static void VerifySteam() { if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { return; } var inst = Installation.Load(); var steamCmdExe = Path.Combine(inst.InstallationPath, "steamcmd.exe"); try { if (FileActions.VerifyFile(steamCmdExe)) { return; } var zipTarget = Path.Combine(Path.GetTempPath(), Path.GetTempFileName()); FileActions.Download(DownloadLink, zipTarget); FileActions.ExtractZip(zipTarget, inst.InstallationPath); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
/// <summary> /// Downloads and installs RocketMod. /// </summary> public static void UpdateRocket() { var tempZip = Path.Combine(Path.GetTempPath(), Path.GetTempFileName()); if (!FileActions.Download(RocketDownloadUrl.Value, tempZip)) { MessageBox.Show( "An error occured during download. Please verify that you can access github.", "Rocketmod download failed", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } FileActions.ExtractZip(tempZip, ServerPath.Value); }
private void Install_Click(object sender, EventArgs e) { Hide(); var pluginLocation = Path.Combine(_server, "Rocket", "Plugins"); var librariesLocation = Path.Combine(_server, "Rocket", "Libraries"); var moduleLocation = Path.Combine(ServerPath.Value, "Modules"); var tempName = Path.GetTempFileName(); var tempLocation = Path.Combine(Path.GetTempPath(), tempName.Substring(0, tempName.Length - 4)); var result = OpenZip.ShowDialog(); if (result == DialogResult.OK) { var stream = (FileStream)OpenZip.OpenFile(); FileActions.ExtractZip(stream.Name, tempLocation); var tempLibraries = Path.Combine(tempLocation, "Libraries"); if (FileActions.VerifyPath(tempLibraries, false)) { var folder = new DirectoryInfo(tempLibraries); var content = folder.GetFiles("*.dll", SearchOption.TopDirectoryOnly); foreach (var file in content) { var dest = Path.Combine(librariesLocation, file.Name); if (File.Exists(dest)) { File.Delete(dest); } FileActions.VerifyFilePath(dest, true); file.MoveTo(dest); } } var tempPlugins = Path.Combine(tempLocation, "Plugins"); if (FileActions.VerifyPath(tempPlugins, false)) { var folder = new DirectoryInfo(tempPlugins); var content = folder.GetFiles("*.dll", SearchOption.TopDirectoryOnly); foreach (var file in content) { var dest = Path.Combine(pluginLocation, file.Name); if (File.Exists(dest)) { File.Delete(dest); } FileActions.VerifyFilePath(dest, true); file.MoveTo(dest); } } var tempModules = Path.Combine(tempLocation, "Modules"); if (FileActions.VerifyPath(tempModules, false)) { var folder = new DirectoryInfo(tempModules); var content = folder.GetFiles("*.dll", SearchOption.TopDirectoryOnly); foreach (var file in content) { var dest = Path.Combine(moduleLocation, file.Name); if (File.Exists(dest)) { File.Delete(dest); } FileActions.VerifyFilePath(dest, true); file.MoveTo(dest); } } } LoadInstalled(); Show(); }