diff --git a/src/StardewModdingAPI/Logger.cs b/src/StardewModdingAPI/Logger.cs index 0d69b6ec..32da124f 100644 --- a/src/StardewModdingAPI/Logger.cs +++ b/src/StardewModdingAPI/Logger.cs @@ -30,7 +30,7 @@ namespace StardewModdingAPI public static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) { Console.WriteLine("An exception has been caught"); - File.WriteAllText(Constants.LogDir + "\\MODDED_ErrorLog.Log_" + DateTime.UtcNow.Ticks + ".txt", e.ExceptionObject.ToString()); + File.WriteAllText(Path.Combine(Constants.LogDir, $"MODDED_ErrorLog.Log_{DateTime.UtcNow.Ticks}.txt"), e.ExceptionObject.ToString()); } /// @@ -40,7 +40,7 @@ namespace StardewModdingAPI public static void Application_ThreadException(object sender, ThreadExceptionEventArgs e) { Console.WriteLine("A thread exception has been caught"); - File.WriteAllText(Constants.LogDir + "\\MODDED_ErrorLog.Log_" + Extensions.Random.Next(100000000, 999999999) + ".txt", e.Exception.ToString()); + File.WriteAllText(Path.Combine(Constants.LogDir, $"MODDED_ErrorLog.Log_{Extensions.Random.Next(100000000, 999999999)}.txt"), e.Exception.ToString()); } #endregion diff --git a/src/StardewModdingAPI/Mod.cs b/src/StardewModdingAPI/Mod.cs index 8edfcf7e..e83049de 100644 --- a/src/StardewModdingAPI/Mod.cs +++ b/src/StardewModdingAPI/Mod.cs @@ -17,7 +17,7 @@ namespace StardewModdingAPI /// /// A basic path to store your mod's config at. /// - public string BaseConfigPath => PathOnDisk + "\\config.json"; + public string BaseConfigPath => Path.Combine(this.PathOnDisk, "config.json"); /// /// A basic path to where per-save configs are stored diff --git a/src/StardewModdingAPI/Program.cs b/src/StardewModdingAPI/Program.cs index 81e48c7d..5513b23a 100644 --- a/src/StardewModdingAPI/Program.cs +++ b/src/StardewModdingAPI/Program.cs @@ -19,6 +19,11 @@ namespace StardewModdingAPI { public class Program { + /// The full path to the Stardew Valley executable. + private static readonly string GameExecutablePath = File.Exists(Path.Combine(Constants.ExecutionPath, "StardewValley.exe")) + ? Path.Combine(Constants.ExecutionPath, "StardewValley.exe") // Linux or Mac + : Path.Combine(Constants.ExecutionPath, "Stardew Valley.exe"); // Windows + private static List _modPaths; public static SGame gamePtr; @@ -103,9 +108,9 @@ namespace StardewModdingAPI //_modContentPaths.ForEach(path => VerifyPath(path)); VerifyPath(Constants.LogDir); - if (!File.Exists(Constants.ExecutionPath + "\\Stardew Valley.exe")) + if (!File.Exists(GameExecutablePath)) { - throw new FileNotFoundException($"Could not found: {Constants.ExecutionPath}\\Stardew Valley.exe"); + throw new FileNotFoundException($"Could not found: {GameExecutablePath}"); } } @@ -117,7 +122,7 @@ namespace StardewModdingAPI Log.AsyncY("Initializing SDV Assembly..."); // Load in the assembly - ignores security - StardewAssembly = Assembly.UnsafeLoadFrom(Constants.ExecutionPath + "\\Stardew Valley.exe"); + StardewAssembly = Assembly.UnsafeLoadFrom(GameExecutablePath); StardewProgramType = StardewAssembly.GetType("StardewValley.Program", true); StardewGameInfo = StardewProgramType.GetField("gamePtr");