summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2016-10-26 21:05:11 -0400
committerJesse Plamondon-Willard <github@jplamondonw.com>2016-10-26 21:05:11 -0400
commit57da69c87c9befcba3257af8e47a7e1685f98041 (patch)
treee6bb5d5cbd1ff1ecdf5a17c4ca93ce93bdc2f5c1
parent2be6ad15744e7230030e0b48f775603d83ff14f7 (diff)
downloadSMAPI-57da69c87c9befcba3257af8e47a7e1685f98041.tar.gz
SMAPI-57da69c87c9befcba3257af8e47a7e1685f98041.tar.bz2
SMAPI-57da69c87c9befcba3257af8e47a7e1685f98041.zip
use platform-agnostic paths (#126)
-rw-r--r--src/StardewModdingAPI/Logger.cs4
-rw-r--r--src/StardewModdingAPI/Mod.cs2
-rw-r--r--src/StardewModdingAPI/Program.cs11
3 files changed, 11 insertions, 6 deletions
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());
}
/// <summary>
@@ -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
/// <summary>
/// A basic path to store your mod's config at.
/// </summary>
- public string BaseConfigPath => PathOnDisk + "\\config.json";
+ public string BaseConfigPath => Path.Combine(this.PathOnDisk, "config.json");
/// <summary>
/// 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
{
+ /// <summary>The full path to the Stardew Valley executable.</summary>
+ 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<string> _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");