mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-25 21:07:20 -08:00
46 lines
1.4 KiB
C#
46 lines
1.4 KiB
C#
|
using System.Diagnostics;
|
|||
|
using System.IO;
|
|||
|
using System.Runtime.Versioning;
|
|||
|
|
|||
|
namespace SourceGit.Native {
|
|||
|
[SupportedOSPlatform("macOS")]
|
|||
|
internal class MacOS : OS.IBackend {
|
|||
|
public string FindGitInstallDir() {
|
|||
|
if (File.Exists("/usr/bin/git")) return "/usr/bin/git";
|
|||
|
return string.Empty;
|
|||
|
}
|
|||
|
|
|||
|
public string FindVSCode() {
|
|||
|
if (File.Exists("/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code")) {
|
|||
|
return "/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code";
|
|||
|
}
|
|||
|
|
|||
|
return string.Empty;
|
|||
|
}
|
|||
|
|
|||
|
public void OpenBrowser(string url) {
|
|||
|
Process.Start("open", url);
|
|||
|
}
|
|||
|
|
|||
|
public void OpenInFileManager(string path, bool select) {
|
|||
|
if (Directory.Exists(path)) {
|
|||
|
Process.Start("open", path);
|
|||
|
} else if (File.Exists(path)) {
|
|||
|
Process.Start("open", $"\"{path}\" -a Finder");
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void OpenTerminal(string workdir) {
|
|||
|
Process.Start(new ProcessStartInfo() {
|
|||
|
WorkingDirectory = workdir,
|
|||
|
FileName = "/Applications/Utilities/Terminal.app/Contents/MacOS/Terminal",
|
|||
|
UseShellExecute = false,
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
public void OpenWithDefaultEditor(string file) {
|
|||
|
Process.Start("open", file);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|