Skip to content

Commit

Permalink
Add support for macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelJBerk committed Dec 25, 2024
1 parent b16c396 commit 40116e5
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions src/IntelOrca.OpenLauncher.Core/InstallService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,15 @@ public string ExecutablePath
{
get
{
var isWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
var binaryName = isWindows ? $"{_game.BinaryName}.exe" : _game.BinaryName;
string binaryName;
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) {
binaryName = $"{_game.BinaryName}.exe";
} else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) {
// We need to use Name and not BinaryName since BinaryName isn't capitalized
binaryName = $"{_game.Name}.app/Contents/MacOS/{_game.Name}";
} else {
binaryName = _game.BinaryName;
}
return Path.Combine(BinPath, binaryName);
}
}
Expand Down Expand Up @@ -158,7 +165,11 @@ private void ExtractArchive(Shell shell, Uri uri, string archivePath, string out
{
if (uri.LocalPath.EndsWith(".zip", StringComparison.OrdinalIgnoreCase))
{
ZipFile.ExtractToDirectory(archivePath, outDirectory, overwriteFiles: true);
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) {
ExtractArchiveMac(archivePath, outDirectory);
} else {
ZipFile.ExtractToDirectory(archivePath, outDirectory, overwriteFiles: true);
}
}
else if (uri.LocalPath.EndsWith(".AppImage", StringComparison.OrdinalIgnoreCase))
{
Expand Down Expand Up @@ -192,5 +203,13 @@ private void ExtractArchive(Shell shell, Uri uri, string archivePath, string out
throw new Exception("Unknown file format to extract.");
}
}

private void ExtractArchiveMac(string archivePath, string outDirectory) {
var dittoProcess = new Process();
var args = $"-k -x \"{archivePath}\" \"{outDirectory}\"";
dittoProcess.StartInfo = new ProcessStartInfo("/usr/bin/ditto", args);
dittoProcess.Start();
dittoProcess.WaitForExit();
}
}
}

0 comments on commit 40116e5

Please sign in to comment.