From 7f4af8b6c697e19da031cbfc5a8b30edba18b7b8 Mon Sep 17 00:00:00 2001 From: JoshuaMKW <60854312+JoshuaMKW@users.noreply.github.com> Date: Mon, 17 Aug 2020 21:25:01 -0500 Subject: [PATCH] Code cleanup --- installer.cs | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/installer.cs b/installer.cs index ca379cd..1f529c7 100644 --- a/installer.cs +++ b/installer.cs @@ -1,6 +1,4 @@ -#define SOURCE - -using System; +using System; using System.IO; using System.Linq; using System.Runtime.InteropServices; @@ -43,7 +41,7 @@ public class Installer while (handled == false) { - Console.Write("{0} ({1}): ", msg, String.Join("/", options)); + Console.Write("{0} ({1}): ", msg, String.Join("|", options)); input = Console.ReadLine(); if (options.Any(s => s.Contains(input.ToLower()))) @@ -79,6 +77,8 @@ public class Installer { DirectoryInfo cwd = new DirectoryInfo(Path.Combine(Directory.GetCurrentDirectory())); DirectoryInfo programspace = new DirectoryInfo(this.programfolder); + + bool validinstall = false; try { @@ -98,6 +98,7 @@ public class Installer if (ext.Contains(file.Extension.ToLower())) { if (file.Extension.ToLower() == ".exe" && file.Name != "GeckoLoader.exe") continue; + if (file.Name.ToLower() == "geckoloader.py" || file.Name.ToLower() == "geckoloader.exe") validinstall = true; file.CopyTo(Path.Combine(programspace.FullName, file.Name), true); } } @@ -119,7 +120,7 @@ public class Installer return false; } - return true; + return validinstall; } public void GetUserInput() @@ -127,22 +128,29 @@ public class Installer string status; string[] options = { "y", "n" }; - Console.SetWindowSize(80, 7); + Console.SetWindowSize(84, 30); Console.Title = "GeckoLoader Installer"; Console.WriteLine("This installer modifies the Windows User PATH variable\n"); status = HandleConsoleQuestion("Are you sure you want to continue?", options); + if (status.ToLower() == "y") { this.SetProgramFolderToPath("GeckoLoader"); - this.MoveFilesToprogramfolder("*", this.copyfiles, this.overwrite); - - Console.WriteLine("Finished installation successfully! You can run GeckoLoader from anywhere\nby simply calling \"GeckoLoader [options]\""); + if (this.MoveFilesToprogramfolder("*", this.copyfiles, this.overwrite) == false) + { + Console.WriteLine("Failed to install :( Is Geckoloader and its dependancies in the same directory?"); + } + else + { + Console.WriteLine("Finished installation successfully! You can run GeckoLoader from anywhere\nby simply calling \"GeckoLoader [options]\""); + } } else { Console.WriteLine("That's okay! You can always run this program again when you feel ready."); } - //Console.ReadKey(); + Console.Write("Press any key to exit . . . "); + Console.ReadKey(); } }