diff --git a/AM2RLauncher/AM2RLauncher.Gtk/Program.cs b/AM2RLauncher/AM2RLauncher.Gtk/Program.cs
index 8b347e8..3c3b81b 100644
--- a/AM2RLauncher/AM2RLauncher.Gtk/Program.cs
+++ b/AM2RLauncher/AM2RLauncher.Gtk/Program.cs
@@ -27,7 +27,7 @@ internal static class MainClass
[STAThread]
public static void Main()
{
- string launcherDataPath = CrossPlatformOperations.CURRENTPATH;
+ string launcherDataPath = CrossPlatformOperations.CurrentPath;
// Make sure first, ~/.local/share/AM2RLauncher exists
if (!Directory.Exists(launcherDataPath))
diff --git a/AM2RLauncher/AM2RLauncher.Mac/Program.cs b/AM2RLauncher/AM2RLauncher.Mac/Program.cs
index 439ce0b..27bfe6a 100644
--- a/AM2RLauncher/AM2RLauncher.Mac/Program.cs
+++ b/AM2RLauncher/AM2RLauncher.Mac/Program.cs
@@ -25,7 +25,7 @@ internal static class MainClass
[STAThread]
public static void Main()
{
- string launcherDataPath = CrossPlatformOperations.CURRENTPATH;
+ string launcherDataPath = CrossPlatformOperations.CurrentPath;
// Make sure first, ~/.local/share/AM2RLauncher exists
if (!Directory.Exists(launcherDataPath))
diff --git a/AM2RLauncher/AM2RLauncher.Wpf/Program.cs b/AM2RLauncher/AM2RLauncher.Wpf/Program.cs
index 77801c8..5fc854c 100644
--- a/AM2RLauncher/AM2RLauncher.Wpf/Program.cs
+++ b/AM2RLauncher/AM2RLauncher.Wpf/Program.cs
@@ -24,7 +24,7 @@ internal static class MainClass
[STAThread]
public static void Main()
{
- string launcherDataPath = CrossPlatformOperations.CURRENTPATH;
+ string launcherDataPath = CrossPlatformOperations.CurrentPath;
// Make sure first, that the path exists
if (!Directory.Exists(launcherDataPath))
diff --git a/AM2RLauncher/AM2RLauncher/LauncherUpdater.cs b/AM2RLauncher/AM2RLauncher/LauncherUpdater.cs
index 98b13a5..8d7840b 100644
--- a/AM2RLauncher/AM2RLauncher/LauncherUpdater.cs
+++ b/AM2RLauncher/AM2RLauncher/LauncherUpdater.cs
@@ -22,10 +22,10 @@ namespace AM2RLauncher
public const string VERSION = Core.Core.Version;
/// The Path of the oldConfig. Only gets used Windows-only
- private static readonly string oldConfigPath = CrossPlatformOperations.CURRENTPATH + "/" + CrossPlatformOperations.LAUNCHERNAME + ".oldCfg";
+ private static readonly string oldConfigPath = CrossPlatformOperations.CurrentPath + "/" + CrossPlatformOperations.LauncherName + ".oldCfg";
/// The actual Path where the executable is stored, only used for updating.
- private static readonly string updatePath = OS.IsWindows ? CrossPlatformOperations.CURRENTPATH
+ private static readonly string updatePath = OS.IsWindows ? CrossPlatformOperations.CurrentPath
: (OS.IsLinux ? Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory) : Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory + "../../../"));
///
@@ -43,33 +43,33 @@ namespace AM2RLauncher
// Update section
// Clean old files that have been left
- if (File.Exists(CrossPlatformOperations.CURRENTPATH + "/AM2RLauncher.bak"))
+ if (File.Exists(CrossPlatformOperations.CurrentPath + "/AM2RLauncher.bak"))
{
log.Info("AM2RLauncher.bak detected. Removing file.");
- File.Delete(CrossPlatformOperations.CURRENTPATH + "/AM2RLauncher.bak");
+ File.Delete(CrossPlatformOperations.CurrentPath + "/AM2RLauncher.bak");
}
if (OS.IsWindows && File.Exists(oldConfigPath))
{
- log.Info(CrossPlatformOperations.LAUNCHERNAME + ".oldCfg detected. Removing file.");
+ log.Info(CrossPlatformOperations.LauncherName + ".oldCfg detected. Removing file.");
File.Delete(oldConfigPath);
}
- if (OS.IsWindows && Directory.Exists(CrossPlatformOperations.CURRENTPATH + "/oldLib"))
+ if (OS.IsWindows && Directory.Exists(CrossPlatformOperations.CurrentPath + "/oldLib"))
{
log.Info("Old lib folder detected, removing folder.");
- Directory.Delete(CrossPlatformOperations.CURRENTPATH + "/oldLib", true);
+ Directory.Delete(CrossPlatformOperations.CurrentPath + "/oldLib", true);
}
// Clean up old update libs
- if (OS.IsWindows && Directory.Exists(CrossPlatformOperations.CURRENTPATH + "/lib"))
+ if (OS.IsWindows && Directory.Exists(CrossPlatformOperations.CurrentPath + "/lib"))
{
- foreach (FileInfo file in new DirectoryInfo(CrossPlatformOperations.CURRENTPATH + "/lib").GetFiles())
+ foreach (FileInfo file in new DirectoryInfo(CrossPlatformOperations.CurrentPath + "/lib").GetFiles())
{
if (file.Name.EndsWith(".bak"))
file.Delete();
}
// Do the same for each subdirectory
- foreach (DirectoryInfo dir in new DirectoryInfo(CrossPlatformOperations.CURRENTPATH + "/lib").GetDirectories())
+ foreach (DirectoryInfo dir in new DirectoryInfo(CrossPlatformOperations.CurrentPath + "/lib").GetDirectories())
{
foreach (FileInfo file in dir.GetFiles())
{
@@ -144,8 +144,8 @@ namespace AM2RLauncher
log.Info("Current version (" + VERSION + ") is outdated! Initiating update for version " + onlineVersion + ".");
- string tmpUpdatePath = CrossPlatformOperations.CURRENTPATH + "/tmpupdate/";
- string zipPath = CrossPlatformOperations.CURRENTPATH + "/launcher.zip";
+ string tmpUpdatePath = CrossPlatformOperations.CurrentPath + "/tmpupdate/";
+ string zipPath = CrossPlatformOperations.CurrentPath + "/launcher.zip";
// Clean tmpupdate
if (Directory.Exists(tmpUpdatePath))
@@ -177,27 +177,27 @@ namespace AM2RLauncher
log.Info("Updates successfully extracted to " + tmpUpdatePath);
File.Delete(zipPath);
- File.Move(updatePath + "/" + CrossPlatformOperations.LAUNCHERNAME, CrossPlatformOperations.CURRENTPATH + "/AM2RLauncher.bak");
- if (OS.IsWindows) File.Move(CrossPlatformOperations.LAUNCHERNAME + ".config", CrossPlatformOperations.LAUNCHERNAME + ".oldCfg");
+ File.Move(updatePath + "/" + CrossPlatformOperations.LauncherName, CrossPlatformOperations.CurrentPath + "/AM2RLauncher.bak");
+ if (OS.IsWindows) File.Move(CrossPlatformOperations.LauncherName + ".config", CrossPlatformOperations.LauncherName + ".oldCfg");
foreach (var file in new DirectoryInfo(tmpUpdatePath).GetFiles())
{
- log.Info("Moving " + file.FullName + " to " + CrossPlatformOperations.CURRENTPATH + "/" + file.Name);
+ log.Info("Moving " + file.FullName + " to " + CrossPlatformOperations.CurrentPath + "/" + file.Name);
File.Copy(file.FullName, updatePath + "/" + file.Name, true);
}
// For windows, the actual application is in "AM2RLauncher.dll". Which means, we need to update the lib folder as well.
- if (OS.IsWindows && Directory.Exists(CrossPlatformOperations.CURRENTPATH + "/lib"))
+ if (OS.IsWindows && Directory.Exists(CrossPlatformOperations.CurrentPath + "/lib"))
{
// So, because Windows behavior is dumb...
// Rename all files in lib to *.bak
- foreach (FileInfo file in new DirectoryInfo(CrossPlatformOperations.CURRENTPATH + "/lib").GetFiles())
+ foreach (FileInfo file in new DirectoryInfo(CrossPlatformOperations.CurrentPath + "/lib").GetFiles())
{
file.CopyTo(file.Directory + "/" + file.Name + ".bak");
}
// Do the same for each sub directory
- foreach (DirectoryInfo dir in new DirectoryInfo(CrossPlatformOperations.CURRENTPATH + "/lib").GetDirectories())
+ foreach (DirectoryInfo dir in new DirectoryInfo(CrossPlatformOperations.CurrentPath + "/lib").GetDirectories())
{
foreach (FileInfo file in dir.GetFiles())
{
@@ -207,7 +207,7 @@ namespace AM2RLauncher
// Yes, the above calls could be recursive. No, I can't be bothered to make them as such.
if (Directory.Exists(tmpUpdatePath + "lib"))
- HelperMethods.DirectoryCopy(tmpUpdatePath + "lib", CrossPlatformOperations.CURRENTPATH + "/lib");
+ HelperMethods.DirectoryCopy(tmpUpdatePath + "lib", CrossPlatformOperations.CurrentPath + "/lib");
}
Directory.Delete(tmpUpdatePath, true);
@@ -217,7 +217,7 @@ namespace AM2RLauncher
log.Info("Files extracted. Preparing to restart executable...");
if (OS.IsLinux) System.Diagnostics.Process.Start("chmod", "+x " + updatePath + "./AM2RLauncher.Gtk");
- System.Diagnostics.Process.Start(updatePath + "/" + CrossPlatformOperations.LAUNCHERNAME);
+ System.Diagnostics.Process.Start(updatePath + "/" + CrossPlatformOperations.LauncherName);
Environment.Exit(0);
}
else
diff --git a/AM2RLauncher/AM2RLauncher/MainForm/MainForm.Events.cs b/AM2RLauncher/AM2RLauncher/MainForm/MainForm.Events.cs
index 1ea0ed9..c912167 100644
--- a/AM2RLauncher/AM2RLauncher/MainForm/MainForm.Events.cs
+++ b/AM2RLauncher/AM2RLauncher/MainForm/MainForm.Events.cs
@@ -287,7 +287,7 @@ namespace AM2RLauncher
log.Error(ex.Message + "\n*****Stack Trace*****\n\n" + ex.StackTrace);
MessageBox.Show(this, ex.Message + "\n*****Stack Trace*****\n\n" + ex.StackTrace, Text.ErrorWindowTitle, MessageBoxType.Error);
- if (Directory.Exists(CrossPlatformOperations.CURRENTPATH + " / PatchData"))
+ if (Directory.Exists(CrossPlatformOperations.CurrentPath + " / PatchData"))
HelperMethods.DeleteDirectory(Core.Core.PatchDataPath);
successful = false;
}
diff --git a/AM2RLauncher/AM2RLauncher/MainForm/MainForm.Methods.cs b/AM2RLauncher/AM2RLauncher/MainForm/MainForm.Methods.cs
index 9fee901..9e3452b 100644
--- a/AM2RLauncher/AM2RLauncher/MainForm/MainForm.Methods.cs
+++ b/AM2RLauncher/AM2RLauncher/MainForm/MainForm.Methods.cs
@@ -82,7 +82,7 @@ namespace AM2RLauncher
{
OpenFileDialog fileDialog = new OpenFileDialog
{
- Directory = new Uri(CrossPlatformOperations.CURRENTPATH),
+ Directory = new Uri(CrossPlatformOperations.CurrentPath),
MultiSelect = false,
Title = title
};
@@ -133,8 +133,8 @@ namespace AM2RLauncher
}
if (OS.IsUnix)
{
- string launcherConfigPath = CrossPlatformOperations.NIXLAUNCHERCONFIGPATH;
- string launcherConfigFilePath = launcherConfigPath + "/config.xml";
+ string launcherConfigFilePath = CrossPlatformOperations.NixLauncherConfigFilePath;
+ string launcherConfigPath = Path.GetDirectoryName(launcherConfigFilePath);
XML.LauncherConfigXML launcherConfig = new XML.LauncherConfigXML();
// If folder doesn't exist, create it and the config file
@@ -178,8 +178,8 @@ namespace AM2RLauncher
}
else if (OS.IsUnix)
{
- string launcherConfigPath = CrossPlatformOperations.NIXLAUNCHERCONFIGPATH;
- string launcherConfigFilePath = CrossPlatformOperations.NIXLAUNCHERCONFIGFILEPATH;
+ string launcherConfigFilePath = CrossPlatformOperations.NixLauncherConfigFilePath;
+ string launcherConfigPath = Path.GetDirectoryName(launcherConfigFilePath);
XML.LauncherConfigXML launcherConfig = new XML.LauncherConfigXML();
// If folder doesn't exist, create it and the config file
@@ -208,8 +208,8 @@ namespace AM2RLauncher
{
if (OS.IsWindows)
{
- string oldConfigPath = CrossPlatformOperations.LAUNCHERNAME + ".oldCfg";
- string newConfigPath = CrossPlatformOperations.LAUNCHERNAME + ".config";
+ string oldConfigPath = CrossPlatformOperations.LauncherName + ".oldCfg";
+ string newConfigPath = CrossPlatformOperations.LauncherName + ".config";
string oldConfigText = File.ReadAllText(oldConfigPath);
string newConfigText = File.ReadAllText(newConfigPath);
@@ -226,7 +226,7 @@ namespace AM2RLauncher
}
else if (OS.IsUnix)
{
- string launcherConfigFilePath = CrossPlatformOperations.NIXLAUNCHERCONFIGFILEPATH;
+ string launcherConfigFilePath = CrossPlatformOperations.NixLauncherConfigFilePath;
// For some reason deserializing and saving back again works, not exactly sure why, but I'll take it
XML.LauncherConfigXML launcherConfig = Serializer.Deserialize(File.ReadAllText(launcherConfigFilePath));
diff --git a/AM2RLauncher/AM2RLauncher/MainForm/MainForm.UI.cs b/AM2RLauncher/AM2RLauncher/MainForm/MainForm.UI.cs
index c5a867c..d6bc975 100644
--- a/AM2RLauncher/AM2RLauncher/MainForm/MainForm.UI.cs
+++ b/AM2RLauncher/AM2RLauncher/MainForm/MainForm.UI.cs
@@ -111,7 +111,7 @@ namespace AM2RLauncher
log.Info("Current OS is: " + OS.Name);
// Set the Current Directory to the path the Launcher is located. Fixes some relative path issues.
- Environment.CurrentDirectory = CrossPlatformOperations.CURRENTPATH;
+ Environment.CurrentDirectory = CrossPlatformOperations.CurrentPath;
log.Info("Set Launcher CWD to " + Environment.CurrentDirectory);
// But log actual folder location nonetheless
diff --git a/AM2RLauncher/AM2RLauncherCore/AM2RLauncher.Core.csproj b/AM2RLauncher/AM2RLauncherCore/AM2RLauncher.Core.csproj
index 995d310..99a490b 100644
--- a/AM2RLauncher/AM2RLauncherCore/AM2RLauncher.Core.csproj
+++ b/AM2RLauncher/AM2RLauncherCore/AM2RLauncher.Core.csproj
@@ -2,7 +2,7 @@
netstandard2.0
- latest
+ default
diff --git a/AM2RLauncher/AM2RLauncherCore/Core.cs b/AM2RLauncher/AM2RLauncherCore/Core.cs
index 2beecac..bff7a5c 100644
--- a/AM2RLauncher/AM2RLauncherCore/Core.cs
+++ b/AM2RLauncher/AM2RLauncherCore/Core.cs
@@ -27,22 +27,22 @@ public static class Core
///
/// Path where the Launcher's PatchData folder is located.
///
- public static readonly string PatchDataPath = CrossPlatformOperations.CURRENTPATH + "/PatchData";
+ public static readonly string PatchDataPath = CrossPlatformOperations.CurrentPath + "/PatchData";
///
/// Path where the AM2R_11.zip is located.
///
- public static readonly string AM2R11File = CrossPlatformOperations.CURRENTPATH + "/AM2R_11.zip";
+ public static readonly string AM2R11File = CrossPlatformOperations.CurrentPath + "/AM2R_11.zip";
///
/// Path where the Launcher's Profiles folder is located.
///
- public static readonly string ProfilesPath = CrossPlatformOperations.CURRENTPATH + "/Profiles";
+ public static readonly string ProfilesPath = CrossPlatformOperations.CurrentPath + "/Profiles";
///
/// Path where the Launcher's Mods folder is located.
///
- public static readonly string ModsPath = CrossPlatformOperations.CURRENTPATH + "/Mods";
+ public static readonly string ModsPath = CrossPlatformOperations.CurrentPath + "/Mods";
///
/// Checks if this is run via WINE.
diff --git a/AM2RLauncher/AM2RLauncherCore/CrossPlatformOperations.cs b/AM2RLauncher/AM2RLauncherCore/CrossPlatformOperations.cs
index b503fb1..6f8b432 100644
--- a/AM2RLauncher/AM2RLauncherCore/CrossPlatformOperations.cs
+++ b/AM2RLauncher/AM2RLauncherCore/CrossPlatformOperations.cs
@@ -1,7 +1,6 @@
using log4net;
using System;
using System.Collections.Generic;
-using System.Configuration;
using System.Diagnostics;
using System.IO;
using System.Reflection;
@@ -21,36 +20,49 @@ public static class CrossPlatformOperations
///
/// Name of the Launcher executable.
///
- public static readonly string LAUNCHERNAME = AppDomain.CurrentDomain.FriendlyName;
+ public static readonly string LauncherName = AppDomain.CurrentDomain.FriendlyName;
///
- /// Path to the Home Folder on *Nix-based systems.
+ /// Path to the Home Folder.
///
- public static readonly string NIXHOME = Environment.GetEnvironmentVariable("HOME");
+ public static readonly string Home = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
///
- /// Path to the Config folder on Linux-based systems.
+ /// Config file path for *nix based systems.
///
- private static readonly string LINUXXDGCONFIG = Environment.GetEnvironmentVariable("XDG_CONFIG_HOME");
+ ///
+ /// Linux: Will point to XDG_CONFIG_HOME/AM2RLauncher/config.xml
+ /// Mac: Will point to ~/Library/Preferences/AM2RLauncher/config.xml.
+ /// Anything else:
+ ///
+ public static string NixLauncherConfigFilePath
+ {
+ get
+ {
+ switch (OS.Name)
+ {
+ case "Linux": return $"{Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)}/AM2RLauncher/config.xml";
+ case "Mac": return $"{Home}/Library/Preferences/AM2RLauncher/config.xml";
+ default: return null;
+ }
+ }
+ }
- ///
- /// Path to the Config file folder on *nix based systems.
- /// Linux: Will point to XDG_CONFIG_HOME/AM2RLauncher
- /// Mac: Will point to ~/Library/Preferences/AM2RLauncher
- ///
- public static readonly string NIXLAUNCHERCONFIGPATH = OS.IsLinux ? (String.IsNullOrWhiteSpace(LINUXXDGCONFIG) ? NIXHOME + "/.config"
- : LINUXXDGCONFIG) + "/AM2RLauncher"
- : NIXHOME + "/Library/Preferences/AM2RLauncher";
+ private static string _currentPath;
///
- /// Config file path for *nix based systems. Will be + "/config.xml".
+ /// Current Path where the Launcher Data is located.
///
- public static readonly string NIXLAUNCHERCONFIGFILEPATH = NIXLAUNCHERCONFIGPATH + "/config.xml";
+ public static string CurrentPath
+ {
+ get
+ {
+ if (_currentPath is null)
+ _currentPath = GenerateCurrentPath();
- ///
- /// Current Path where the Launcher is located. For more info, check .
- ///
- public static readonly string CURRENTPATH = GenerateCurrentPath();
+ return _currentPath;
+ }
+ }
///
/// Generates the mirror list, depending on the current Platform.
@@ -116,7 +128,7 @@ public static class CrossPlatformOperations
// We have to replace forward slashes with backslashes here on windows because explorer.exe is picky...
// And on Nix systems, we want to replace ~ with its corresponding env var
string realPath = OS.IsWindows ? Environment.ExpandEnvironmentVariables(path).Replace("/", "\\")
- : path.Replace("~", NIXHOME);
+ : path.Replace("~", Home);
if (!Directory.Exists(realPath))
{
log.Info(realPath + " did not exist and was created");
@@ -146,7 +158,7 @@ public static class CrossPlatformOperations
// We have to replace forward slashes with backslashes here on windows because explorer.exe is picky...
// And on nix systems, we want to replace ~ with its corresponding env var
string realPath = OS.IsWindows ? Environment.ExpandEnvironmentVariables(path).Replace("/", "\\")
- : path.Replace("~", NIXHOME);
+ : path.Replace("~", Home);
if (!File.Exists(realPath))
{
log.Error(realPath + "did not exist, operation to open its folder was cancelled!");
@@ -257,16 +269,16 @@ public static class CrossPlatformOperations
if (original == output)
output += "_";
- string arguments = "-f -d -s \"" + original.Replace(CURRENTPATH + "/", "") + "\" \"" + patch.Replace(CURRENTPATH + "/", "")
- + "\" \"" + output.Replace(CURRENTPATH + "/", "") + "\"";
+ string arguments = "-f -d -s \"" + original.Replace(CurrentPath + "/", "") + "\" \"" + patch.Replace(CurrentPath + "/", "")
+ + "\" \"" + output.Replace(CurrentPath + "/", "") + "\"";
if (OS.IsWindows)
{
// We want some fancy parameters for Windows because the terminal scares end users :(
ProcessStartInfo parameters = new ProcessStartInfo
{
- FileName = CURRENTPATH + "/PatchData/utilities/xdelta/xdelta3.exe",
- WorkingDirectory = CURRENTPATH + "",
+ FileName = CurrentPath + "/PatchData/utilities/xdelta/xdelta3.exe",
+ WorkingDirectory = CurrentPath + "",
UseShellExecute = false,
CreateNoWindow = true,
Arguments = arguments
@@ -282,7 +294,7 @@ public static class CrossPlatformOperations
{
FileName = "xdelta3",
Arguments = arguments,
- WorkingDirectory = CURRENTPATH
+ WorkingDirectory = CurrentPath
};
using Process proc = Process.Start(parameters);
@@ -333,19 +345,20 @@ public static class CrossPlatformOperations
}
///
- /// Figures out what the AM2RLauncher's should be.
+ /// Figures out what the AM2RLauncher's should be.
+ ///
+ ///
/// Determination is as follows:
///
/// - $AM2RLAUNCHERDATA environment variable is read and folders are recursively generated.
/// - The current OS is checked. For Windows, the path where the executable is located will be returned.
/// For Linux, $XDG_DATA_HOME/AM2RLauncher will be returned.
/// Should $XDG_DATA_HOME be empty, it will default to $HOME/.local/share.
- /// For Mac, HOME/Library/AM2RLauncher" will be returned.
+ /// For Mac, HOME/Library/Application Support/AM2RLauncher" will be returned.
/// - The path where the executable is located will be returned.
///
- /// Should any errors occur, it falls down to the next step.
- ///
- ///
+ /// Should any errors occur, it falls down to the next step.
+ /// The path where the AM2RLauncher can store its data.
private static string GenerateCurrentPath()
{
// First, we check if the user has a custom AM2RLAUNCHERDATA env var
@@ -375,35 +388,26 @@ public static class CrossPlatformOperations
}
else if (OS.IsLinux)
{
- // First check if XDG_DATA_HOME is set, if not we'll use ~/.local/share
- string xdgDataHome = Environment.GetEnvironmentVariable("XDG_DATA_HOME");
- if (String.IsNullOrWhiteSpace(xdgDataHome))
- {
- log.Info("Using default Linux CurrentPath.");
- xdgDataHome = NIXHOME + "/.local/share";
- }
- // Add AM2RLauncher to the end of the dataPath
- xdgDataHome += "/AM2RLauncher";
+ // Linux has the Path at XDG_DATA_HOME/AM2RLauncher
+ string linuxPath = $"{Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)}/AM2RLauncher";
try
{
- // This will create the directories recursively if they don't exist
- Directory.CreateDirectory(xdgDataHome);
-
- // Our env var is now set and directories exist
- log.Info("CurrentPath is set to " + xdgDataHome);
- return xdgDataHome;
+ Directory.CreateDirectory(linuxPath);
+ log.Info($"CurrentPath is set to {linuxPath}");
+ return linuxPath;
}
catch (Exception ex)
{
- log.Error($"There was an error with '{xdgDataHome}'!\n{ex.Message} {ex.StackTrace}. Falling back to defaults.");
+ log.Error($"There was an error with '{linuxPath}'!\n{ex.Message} {ex.StackTrace}. Falling back to defaults.");
}
}
else if (OS.IsMac)
{
- //Mac has the Path at HOME/Library/AM2RLauncher
- string macPath = NIXHOME + "/Library/AM2RLauncher";
+ // Cannot use SpecialFolders here, as the current .NET version returns them wrongly.
+ // Mac has the Path at HOME/Application Support/Library/AM2RLauncher
+ string macPath = Home + "/Library/Application Support/AM2RLauncher";
try
{
Directory.CreateDirectory(macPath);
@@ -421,6 +425,4 @@ public static class CrossPlatformOperations
log.Info("Something went wrong, falling back to the default CurrentPath.");
return Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory);
}
-
-
}
\ No newline at end of file
diff --git a/AM2RLauncher/AM2RLauncherCore/Profile.cs b/AM2RLauncher/AM2RLauncherCore/Profile.cs
index 77d1ca8..d714e7f 100644
--- a/AM2RLauncher/AM2RLauncherCore/Profile.cs
+++ b/AM2RLauncher/AM2RLauncherCore/Profile.cs
@@ -296,15 +296,15 @@ public static class Profile
log.Info("Attempting to delete profile " + profile.Name + "...");
// Delete folder in Mods
- if (Directory.Exists(CrossPlatformOperations.CURRENTPATH + profile.DataPath))
- HelperMethods.DeleteDirectory(CrossPlatformOperations.CURRENTPATH + profile.DataPath);
+ if (Directory.Exists(CrossPlatformOperations.CurrentPath + profile.DataPath))
+ HelperMethods.DeleteDirectory(CrossPlatformOperations.CurrentPath + profile.DataPath);
// Delete the zip file in Mods
- if (File.Exists(CrossPlatformOperations.CURRENTPATH + profile.DataPath + ".zip"))
+ if (File.Exists(CrossPlatformOperations.CurrentPath + profile.DataPath + ".zip"))
{
// For some reason, it was set at read only, so we undo that here
- File.SetAttributes(CrossPlatformOperations.CURRENTPATH + profile.DataPath + ".zip", FileAttributes.Normal);
- File.Delete(CrossPlatformOperations.CURRENTPATH + profile.DataPath + ".zip");
+ File.SetAttributes(CrossPlatformOperations.CurrentPath + profile.DataPath + ".zip", FileAttributes.Normal);
+ File.Delete(CrossPlatformOperations.CurrentPath + profile.DataPath + ".zip");
}
// Delete folder in Profiles
@@ -368,7 +368,7 @@ public static class Profile
log.Info("Profile folder created and AM2R_11.zip extracted.");
// Set local dataPath for installation files
- var dataPath = CrossPlatformOperations.CURRENTPATH + profile.DataPath;
+ var dataPath = CrossPlatformOperations.CurrentPath + profile.DataPath;
string datawin = null, exe = null;
@@ -555,8 +555,8 @@ public static class Profile
// Create working dir after some cleanup
string apktoolPath = Core.PatchDataPath + "/utilities/android/apktool.jar",
uberPath = Core.PatchDataPath + "/utilities/android/uber-apk-signer.jar",
- tempDir = new DirectoryInfo(CrossPlatformOperations.CURRENTPATH + "/temp").FullName,
- dataPath = CrossPlatformOperations.CURRENTPATH + profile.DataPath;
+ tempDir = new DirectoryInfo(CrossPlatformOperations.CurrentPath + "/temp").FullName,
+ dataPath = CrossPlatformOperations.CurrentPath + profile.DataPath;
if (Directory.Exists(tempDir))
Directory.Delete(tempDir, true);
Directory.CreateDirectory(tempDir);
@@ -615,14 +615,14 @@ public static class Profile
CrossPlatformOperations.RunJavaJar("\"" + uberPath + "\" -a \"" + profile.Name + ".apk\"", tempDir);
// Extra file cleanup
- File.Copy(tempDir + "/" + profile.Name + "-aligned-debugSigned.apk", CrossPlatformOperations.CURRENTPATH + "/" + profile.Name + ".apk", true);
- log.Info(profile.Name + ".apk signed and moved to " + CrossPlatformOperations.CURRENTPATH + "/" + profile.Name + ".apk.");
+ File.Copy(tempDir + "/" + profile.Name + "-aligned-debugSigned.apk", CrossPlatformOperations.CurrentPath + "/" + profile.Name + ".apk", true);
+ log.Info(profile.Name + ".apk signed and moved to " + CrossPlatformOperations.CurrentPath + "/" + profile.Name + ".apk.");
HelperMethods.DeleteDirectory(tempDir);
// Done
progress.Report(100);
log.Info("Successfully created Android APK for profile " + profile.Name + ".");
- CrossPlatformOperations.OpenFolderAndSelectFile(CrossPlatformOperations.CURRENTPATH + "/" + profile.Name + ".apk");
+ CrossPlatformOperations.OpenFolderAndSelectFile(CrossPlatformOperations.CurrentPath + "/" + profile.Name + ".apk");
}
///
@@ -632,7 +632,7 @@ public static class Profile
{
// These are used on both windows and linux for game logging
string savePath = OS.IsWindows ? profile.SaveLocation.Replace("%localappdata%", Environment.GetEnvironmentVariable("LOCALAPPDATA"))
- : profile.SaveLocation.Replace("~", CrossPlatformOperations.NIXHOME);
+ : profile.SaveLocation.Replace("~", CrossPlatformOperations.Home);
DirectoryInfo logDir = new DirectoryInfo(savePath + "/logs");
string date = String.Join("-", DateTime.Now.ToString().Split(Path.GetInvalidFileNameChars(), StringSplitOptions.RemoveEmptyEntries));