From 07d0dc38ca210a82264841fd7fe8d2040acee61d Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sat, 5 Nov 2016 19:52:39 -0400 Subject: fix installer on Windows not ignoring quote characters in file path --- src/StardewModdingAPI.Installer/InteractiveInstaller.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/StardewModdingAPI.Installer') diff --git a/src/StardewModdingAPI.Installer/InteractiveInstaller.cs b/src/StardewModdingAPI.Installer/InteractiveInstaller.cs index 022ac4e6..58bc39f0 100644 --- a/src/StardewModdingAPI.Installer/InteractiveInstaller.cs +++ b/src/StardewModdingAPI.Installer/InteractiveInstaller.cs @@ -56,7 +56,7 @@ namespace StardewModdingApi.Installer this.PrintDebug("Collecting information..."); Platform platform = this.DetectPlatform(); DirectoryInfo packageDir = new DirectoryInfo(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), platform.ToString())); - DirectoryInfo installDir = this.InteractivelyGetInstallPath(); + DirectoryInfo installDir = this.InteractivelyGetInstallPath(platform); string executablePath = Path.Combine(installDir.FullName, platform == Platform.Mono ? "StardewValley.exe" : "Stardew Valley.exe"); string unixGameLauncherPath = Path.Combine(installDir.FullName, "StardewValley"); string unixGameLauncherBackupPath = Path.Combine(installDir.FullName, "StardewValley-original"); @@ -276,7 +276,8 @@ namespace StardewModdingApi.Installer } /// Interactively locate the game's install path. - private DirectoryInfo InteractivelyGetInstallPath() + /// The current platform. + private DirectoryInfo InteractivelyGetInstallPath(Platform platform) { // try default paths foreach (string defaultPath in this.DefaultInstallPaths) @@ -292,13 +293,17 @@ namespace StardewModdingApi.Installer // get path from user Console.WriteLine(" Enter the game's full directory path (the one containing 'StardewValley.exe' or 'Stardew Valley.exe')."); Console.Write(" > "); - string path = Console.ReadLine(); + string path = Console.ReadLine()?.Trim(); if (string.IsNullOrWhiteSpace(path)) { Console.WriteLine(" You must specify a directory path to continue."); continue; } + // normalise on Windows + if (platform == Platform.Windows) + path = path.Replace("\"", ""); // in Windows, quotes are used to escape spaces and aren't part of the file path + // get directory if (File.Exists(path)) path = Path.GetDirectoryName(path); -- cgit