mirror of
https://github.com/BepInEx/BepInEx.git
synced 2026-10-20 01:46:13 +00:00
Set GameRootPath to outside the game.app folder on OSX
This commit is contained in:
3 files changed
+22
-3
No files matched your search
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
@@ -11,7 +10,7 @@ namespace BepInEx.Preloader
|
||||
{
|
||||
public static void PreloaderPreMain(string[] args)
|
||||
{
|
||||
string bepinPath = Path.GetDirectoryName(Path.GetDirectoryName(Path.GetFullPath(EnvVars.DOORSTOP_INVOKE_DLL_PATH)));
|
||||
string bepinPath = Utility.ParentDirectory(Path.GetFullPath(EnvVars.DOORSTOP_INVOKE_DLL_PATH), 2);
|
||||
|
||||
Paths.SetExecutablePath(args[0], bepinPath, EnvVars.DOORSTOP_MANAGED_FOLDER_DIR);
|
||||
AppDomain.CurrentDomain.AssemblyResolve += LocalResolve;
|
||||
|
||||
+7
-1
@@ -1,5 +1,6 @@
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using MonoMod.Utils;
|
||||
|
||||
namespace BepInEx
|
||||
{
|
||||
@@ -12,7 +13,11 @@ namespace BepInEx
|
||||
{
|
||||
ExecutablePath = executablePath;
|
||||
ProcessName = Path.GetFileNameWithoutExtension(executablePath);
|
||||
GameRootPath = Path.GetDirectoryName(executablePath);
|
||||
|
||||
GameRootPath = Utility.CurrentOs == Platform.MacOS
|
||||
? Utility.ParentDirectory(executablePath, 4)
|
||||
: Path.GetDirectoryName(executablePath);
|
||||
|
||||
ManagedPath = managedPath ?? Utility.CombinePaths(GameRootPath, $"{ProcessName}_Data", "Managed");
|
||||
BepInExRootPath = bepinRootPath ?? Path.Combine(GameRootPath, "BepInEx");
|
||||
ConfigPath = Path.Combine(BepInExRootPath, "config");
|
||||
@@ -58,6 +63,7 @@ namespace BepInEx
|
||||
|
||||
/// <summary>
|
||||
/// The directory that the currently executing process resides in.
|
||||
/// <para>On OSX however, this is the parent directory of the game.app folder.</para>
|
||||
/// </summary>
|
||||
public static string GameRootPath { get; private set; }
|
||||
|
||||
|
||||
@@ -67,6 +67,20 @@ namespace BepInEx
|
||||
/// <returns>A combined path.</returns>
|
||||
public static string CombinePaths(params string[] parts) => parts.Aggregate(Path.Combine);
|
||||
|
||||
/// <summary>
|
||||
/// Returns the parent directory of a path, optionally specifying the amount of levels.
|
||||
/// </summary>
|
||||
/// <param name="path">The path to get the parent directory of.</param>
|
||||
/// <param name="levels">The amount of levels to traverse. Defaults to 1</param>
|
||||
/// <returns>The parent directory.</returns>
|
||||
public static string ParentDirectory(string path, int levels = 1)
|
||||
{
|
||||
for (int i = 0; i < levels; i++)
|
||||
path = Path.GetDirectoryName(path);
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tries to parse a bool, with a default value if unable to parse.
|
||||
/// </summary>
|
||||
|
||||
Reference in new issue
Block a user