mirror of
https://github.com/BepInEx/BepInEx.git
synced 2026-10-20 01:46:13 +00:00
Implement cross-platform improvements from master
Contains fixes rebased fromd2afe06...9f4dcb6
This commit is contained in:
34 files changed
+1117
-257
No files matched your search
@@ -6,6 +6,7 @@ using System.Reflection;
|
||||
using System.Reflection.Emit;
|
||||
using System.Text;
|
||||
using Mono.Cecil;
|
||||
using MonoMod.Utils;
|
||||
|
||||
namespace BepInEx
|
||||
{
|
||||
@@ -270,5 +271,28 @@ namespace BepInEx
|
||||
|
||||
return builder.ToString();
|
||||
}
|
||||
|
||||
public static Platform CurrentPlatform { get; private set; } = CheckPlatform();
|
||||
|
||||
// Adapted from https://github.com/MonoMod/MonoMod.Common/blob/master/Utils/PlatformHelper.cs#L13
|
||||
private static Platform CheckPlatform()
|
||||
{
|
||||
var pPlatform = typeof(Environment).GetProperty("Platform", BindingFlags.NonPublic | BindingFlags.Static);
|
||||
string platId = pPlatform != null ? pPlatform.GetValue(null, new object[0]).ToString() : Environment.OSVersion.Platform.ToString();
|
||||
platId = platId.ToLowerInvariant();
|
||||
|
||||
var cur = Platform.Unknown;
|
||||
if (platId.Contains("win"))
|
||||
cur = Platform.Windows;
|
||||
else if (platId.Contains("mac") || platId.Contains("osx"))
|
||||
cur = Platform.MacOS;
|
||||
else if (platId.Contains("lin") || platId.Contains("unix"))
|
||||
cur = Platform.Linux;
|
||||
|
||||
if (IntPtr.Size == 8)
|
||||
cur |= Platform.Bits64;
|
||||
|
||||
return cur;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user