summaryrefslogtreecommitdiff
path: root/src/SMAPI.Installer
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2021-03-07 20:15:10 -0500
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2021-03-07 20:15:10 -0500
commit5399239c2be01396958ed454d6ae56f006d20ca5 (patch)
tree87683eda0873a0c24d9bcee5d47f1cec896f21bb /src/SMAPI.Installer
parentdb011ee751bdfb8bbd9abbeb706966db4c4e2461 (diff)
parenta571f459f59a6ecfdd53e3158ba8d29157598920 (diff)
downloadSMAPI-5399239c2be01396958ed454d6ae56f006d20ca5.tar.gz
SMAPI-5399239c2be01396958ed454d6ae56f006d20ca5.tar.bz2
SMAPI-5399239c2be01396958ed454d6ae56f006d20ca5.zip
Merge branch 'develop' into stable
Diffstat (limited to 'src/SMAPI.Installer')
-rw-r--r--src/SMAPI.Installer/InteractiveInstaller.cs12
-rw-r--r--src/SMAPI.Installer/Program.cs25
2 files changed, 36 insertions, 1 deletions
diff --git a/src/SMAPI.Installer/InteractiveInstaller.cs b/src/SMAPI.Installer/InteractiveInstaller.cs
index ff74a659..3d673719 100644
--- a/src/SMAPI.Installer/InteractiveInstaller.cs
+++ b/src/SMAPI.Installer/InteractiveInstaller.cs
@@ -279,6 +279,7 @@ namespace StardewModdingApi.Installer
/*********
** Step 4: validate assumptions
*********/
+ // executable exists
if (!File.Exists(paths.ExecutablePath))
{
this.PrintError("The detected game install path doesn't contain a Stardew Valley executable.");
@@ -286,6 +287,17 @@ namespace StardewModdingApi.Installer
return;
}
+ // game folder doesn't contain paths beyond the max limit
+ {
+ string[] tooLongPaths = PathUtilities.GetTooLongPaths(Path.Combine(paths.GamePath, "Mods")).ToArray();
+ if (tooLongPaths.Any())
+ {
+ this.PrintError($"SMAPI can't install to the detected game folder, because some of its files exceed the maximum {context.Platform} path length.\nIf you need help fixing this error, see https://smapi.io/help\n\nAffected paths:\n {string.Join("\n ", tooLongPaths)}");
+ Console.ReadLine();
+ return;
+ }
+ }
+
/*********
** Step 5: ask what to do
diff --git a/src/SMAPI.Installer/Program.cs b/src/SMAPI.Installer/Program.cs
index 6c479621..d9c31dd6 100644
--- a/src/SMAPI.Installer/Program.cs
+++ b/src/SMAPI.Installer/Program.cs
@@ -3,6 +3,7 @@ using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.IO.Compression;
using System.Reflection;
+using System.Threading;
namespace StardewModdingApi.Installer
{
@@ -49,7 +50,15 @@ namespace StardewModdingApi.Installer
// launch installer
var installer = new InteractiveInstaller(bundleDir.FullName);
- installer.Run(args);
+
+ try
+ {
+ installer.Run(args);
+ }
+ catch (Exception ex)
+ {
+ Program.PrintErrorAndExit($"The installer failed with an unexpected exception.\nIf you need help fixing this error, see https://smapi.io/help\n\n{ex}");
+ }
}
/*********
@@ -76,5 +85,19 @@ namespace StardewModdingApi.Installer
return null;
}
}
+
+ /// <summary>Write an error directly to the console and exit.</summary>
+ /// <param name="message">The error message to display.</param>
+ private static void PrintErrorAndExit(string message)
+ {
+ Console.ForegroundColor = ConsoleColor.Red;
+ Console.WriteLine(message);
+ Console.ResetColor();
+
+ Console.WriteLine("Game has ended. Press any key to exit.");
+ Thread.Sleep(100);
+ Console.ReadKey();
+ Environment.Exit(0);
+ }
}
}