Merge remote-tracking branch 'origin/master'

# Conflicts:
#	.gitignore
This commit is contained in:
jvyden 2022-07-28 17:07:17 -04:00
commit 98dd90a9d5
No known key found for this signature in database
GPG key ID: 18BCF2BE0262B278
5 changed files with 77 additions and 33 deletions

1
.gitignore vendored
View file

@ -396,5 +396,6 @@ FodyWeavers.xsd
# JetBrains Rider # JetBrains Rider
*.sln.iml *.sln.iml
.DS_Store
builds/ builds/

34
UnionPatcher/OSUtil.cs Normal file
View file

@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
namespace LBPUnion.UnionPatcher
{
using RuntimeOSPlatform = System.Runtime.InteropServices.OSPlatform;
public enum OSPlatform
{
NotSupported,
Windows,
OSX,
Linux,
}
public class OSUtil
{
private static IEnumerable
<(OSPlatform Platform, RuntimeOSPlatform RuntimePlatform)?> EnumeratePlatforms()
{
yield return (OSPlatform.Windows, RuntimeOSPlatform.Windows);
yield return (OSPlatform.OSX, RuntimeOSPlatform.OSX);
yield return (OSPlatform.Linux, RuntimeOSPlatform.Linux);
}
public static OSPlatform GetPlatform()
{
return EnumeratePlatforms().FirstOrDefault(p
=> RuntimeInformation.IsOSPlatform(p.Value.RuntimePlatform))?.Platform ?? default;
}
}
}

View file

@ -38,44 +38,53 @@ public class RemotePatch
public static void LaunchSCETool(string args) public static void LaunchSCETool(string args)
{ {
string platformExecutable = ""; string platformExecutable = "";
switch (OSUtil.GetPlatform())
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
platformExecutable = "scetool/win64/scetool.exe";
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
platformExecutable = "scetool/linux64/scetool";
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{ {
if (RuntimeInformation.OSArchitecture == Architecture.Arm64) case OSPlatform.Windows:
{ platformExecutable = "scetool/win64/scetool.exe";
platformExecutable = "scetool/macarm64/scetool"; // For Apple Silicon Macs break;
} case OSPlatform.Linux:
else if(RuntimeInformation.ProcessArchitecture == Architecture.X64)
{ {
platformExecutable = "scetool/mac64/scetool"; platformExecutable = "scetool/linux64/scetool";
} } else if (RuntimeInformation.ProcessArchitecture == Architecture.Arm)
} {
if (platformExecutable != "") platformExecutable = "scetool/linuxarm/scetool";
{ } else if (RuntimeInformation.ProcessArchitecture == Architecture.Arm64)
ProcessStartInfo startInfo = new(); {
startInfo.UseShellExecute = false; platformExecutable = "scetool/linuxarm64/scetool";
startInfo.FileName = Path.GetFullPath(platformExecutable); }
startInfo.WorkingDirectory = Path.GetFullPath("."); break;
startInfo.Arguments = args; case OSPlatform.OSX:
startInfo.RedirectStandardOutput = true; if (RuntimeInformation.OSArchitecture == Architecture.Arm64)
{
platformExecutable = "scetool/macarm64/scetool"; // For Apple Silicon Macs
}
else
{
platformExecutable = "scetool/mac64/scetool";
}
break;
default:
throw new Exception("Error starting SCETool. Your platform may not be supported yet.");
Console.WriteLine("\n\n===== START SCETOOL =====\n"); }
using (Process proc = Process.Start(startInfo))
{
while (!proc.StandardOutput.EndOfStream) Console.WriteLine(proc.StandardOutput.ReadLine());
proc.WaitForExit();
}
Console.WriteLine("\n===== END SCETOOL =====\n\n"); ProcessStartInfo startInfo = new();
} startInfo.UseShellExecute = false;
else startInfo.FileName = Path.GetFullPath(platformExecutable);
startInfo.WorkingDirectory = Path.GetFullPath(".");
startInfo.Arguments = args;
startInfo.RedirectStandardOutput = true;
Console.WriteLine("\n\n===== START SCETOOL =====\n");
using (Process proc = Process.Start(startInfo))
{ {
throw new Exception("Error starting SCETool. Your platform may not be supported yet."); while (!proc.StandardOutput.EndOfStream) Console.WriteLine(proc.StandardOutput.ReadLine());
proc.WaitForExit();
} }
Console.WriteLine("\n===== END SCETOOL =====\n\n");
} }
public void RevertEBOOT(string ps3ip, string gameID, string serverURL, string user, string pass) public void RevertEBOOT(string ps3ip, string gameID, string serverURL, string user, string pass)

Binary file not shown.

Binary file not shown.