Cleanup CrossPlatformOperations

pull/32/head
Miepee 4 years ago
parent c2fa4c27a9
commit 972c59e056

@ -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))

@ -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))

@ -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))

@ -22,10 +22,10 @@ namespace AM2RLauncher
public const string VERSION = Core.Core.Version;
/// <summary>The Path of the oldConfig. Only gets used Windows-only</summary>
private static readonly string oldConfigPath = CrossPlatformOperations.CURRENTPATH + "/" + CrossPlatformOperations.LAUNCHERNAME + ".oldCfg";
private static readonly string oldConfigPath = CrossPlatformOperations.CurrentPath + "/" + CrossPlatformOperations.LauncherName + ".oldCfg";
/// <summary>The actual Path where the executable is stored, only used for updating.</summary>
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 + "../../../"));
/// <summary>
@ -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

@ -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;
}

@ -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<XML.LauncherConfigXML>(File.ReadAllText(launcherConfigFilePath));

@ -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

@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>latest</LangVersion>
<LangVersion>default</LangVersion>
</PropertyGroup>
<ItemGroup>

@ -27,22 +27,22 @@ public static class Core
/// <summary>
/// Path where the Launcher's PatchData folder is located.
/// </summary>
public static readonly string PatchDataPath = CrossPlatformOperations.CURRENTPATH + "/PatchData";
public static readonly string PatchDataPath = CrossPlatformOperations.CurrentPath + "/PatchData";
/// <summary>
/// Path where the AM2R_11.zip is located.
/// </summary>
public static readonly string AM2R11File = CrossPlatformOperations.CURRENTPATH + "/AM2R_11.zip";
public static readonly string AM2R11File = CrossPlatformOperations.CurrentPath + "/AM2R_11.zip";
/// <summary>
/// Path where the Launcher's Profiles folder is located.
/// </summary>
public static readonly string ProfilesPath = CrossPlatformOperations.CURRENTPATH + "/Profiles";
public static readonly string ProfilesPath = CrossPlatformOperations.CurrentPath + "/Profiles";
/// <summary>
/// Path where the Launcher's Mods folder is located.
/// </summary>
public static readonly string ModsPath = CrossPlatformOperations.CURRENTPATH + "/Mods";
public static readonly string ModsPath = CrossPlatformOperations.CurrentPath + "/Mods";
/// <summary>
/// Checks if this is run via WINE.

@ -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
/// <summary>
/// Name of the Launcher executable.
/// </summary>
public static readonly string LAUNCHERNAME = AppDomain.CurrentDomain.FriendlyName;
public static readonly string LauncherName = AppDomain.CurrentDomain.FriendlyName;
/// <summary>
/// Path to the Home Folder on *Nix-based systems.
/// Path to the Home Folder.
/// </summary>
public static readonly string NIXHOME = Environment.GetEnvironmentVariable("HOME");
public static readonly string Home = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
/// <summary>
/// Path to the Config folder on Linux-based systems.
/// Config file path for *nix based systems. <br/>
/// </summary>
private static readonly string LINUXXDGCONFIG = Environment.GetEnvironmentVariable("XDG_CONFIG_HOME");
/// <remarks>
/// Linux: Will point to XDG_CONFIG_HOME/AM2RLauncher/config.xml <br/>
/// Mac: Will point to ~/Library/Preferences/AM2RLauncher/config.xml. <br/>
/// Anything else: <see langword="null"/>
/// </remarks>
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;
}
}
}
/// <summary>
/// Path to the Config file folder on *nix based systems. <br/>
/// Linux: Will point to XDG_CONFIG_HOME/AM2RLauncher <br/>
/// Mac: Will point to ~/Library/Preferences/AM2RLauncher
/// </summary>
public static readonly string NIXLAUNCHERCONFIGPATH = OS.IsLinux ? (String.IsNullOrWhiteSpace(LINUXXDGCONFIG) ? NIXHOME + "/.config"
: LINUXXDGCONFIG) + "/AM2RLauncher"
: NIXHOME + "/Library/Preferences/AM2RLauncher";
private static string _currentPath;
/// <summary>
/// Config file path for *nix based systems. Will be <see cref="NIXLAUNCHERCONFIGPATH"/> + "/config.xml".
/// Current Path where the Launcher Data is located.
/// </summary>
public static readonly string NIXLAUNCHERCONFIGFILEPATH = NIXLAUNCHERCONFIGPATH + "/config.xml";
public static string CurrentPath
{
get
{
if (_currentPath is null)
_currentPath = GenerateCurrentPath();
/// <summary>
/// Current Path where the Launcher is located. For more info, check <see cref="GenerateCurrentPath"/>.
/// </summary>
public static readonly string CURRENTPATH = GenerateCurrentPath();
return _currentPath;
}
}
/// <summary>
/// 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
}
/// <summary>
/// Figures out what the AM2RLauncher's <see cref="CURRENTPATH"/> should be.<br/>
/// Figures out what the AM2RLauncher's <see cref="CurrentPath"/> should be.<br/>
/// </summary>
/// <remarks>
/// Determination is as follows:
/// <list type="number">
/// <item><b>$AM2RLAUNCHERDATA</b> environment variable is read and folders are recursively generated.</item>
/// <item>The current OS is checked. For Windows, the path where the executable is located will be returned.<br/>
/// For Linux, <b>$XDG_DATA_HOME/AM2RLauncher</b> will be returned.
/// Should <b>$XDG_DATA_HOME</b> be empty, it will default to <b>$HOME/.local/share</b>.<br/>
/// For Mac, <b>HOME/Library/AM2RLauncher"</b> will be returned.</item>
/// For Mac, <b>HOME/Library/Application Support/AM2RLauncher"</b> will be returned.</item>
/// <item>The path where the executable is located will be returned.</item>
/// </list>
/// Should any errors occur, it falls down to the next step.
/// </summary>
/// <returns></returns>
/// Should any errors occur, it falls down to the next step.</remarks>
/// <returns>The path where the AM2RLauncher can store its data.</returns>
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);
}
}

@ -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");
}
/// <summary>
@ -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));

Loading…
Cancel
Save