From cb27d3f5519a93b17be264c97ea8851cc8a81c44 Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Wed, 25 May 2011 20:24:25 +0100 Subject: [PATCH] Move the default backend initialisation to SparkleBackend --- SparkleLib/SparkleBackend.cs | 10 +++++++++- SparkleShare/SparkleShare.cs | 6 ++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/SparkleLib/SparkleBackend.cs b/SparkleLib/SparkleBackend.cs index ea44727a..d59164b2 100644 --- a/SparkleLib/SparkleBackend.cs +++ b/SparkleLib/SparkleBackend.cs @@ -22,7 +22,15 @@ namespace SparkleLib { public class SparkleBackend { - public static SparkleBackend DefaultBackend; + public static SparkleBackend DefaultBackend = + new SparkleBackend ("Git", + new string [4] { + "/opt/local/bin/git", + "/usr/bin/git", + "/usr/local/bin/git", + "/usr/local/git/bin/git" + } + ); public string Name; public string Path; diff --git a/SparkleShare/SparkleShare.cs b/SparkleShare/SparkleShare.cs index 2c7cf646..121e6df9 100644 --- a/SparkleShare/SparkleShare.cs +++ b/SparkleShare/SparkleShare.cs @@ -76,10 +76,6 @@ namespace SparkleShare { if (show_help) ShowHelp (p); - // Set the default backend for SparkleLib - string [] git_paths = new string [3] {"/usr/bin/git", "/usr/local/git/bin/git", "/usr/local/bin/git"}; - SparkleBackend.DefaultBackend = new SparkleBackend ("Git", git_paths); - // Load the right controller for the OS string controller_name; switch (SparkleShare.Platform) { @@ -172,11 +168,13 @@ namespace SparkleShare { static PlatformID Platform { get { IntPtr buf = IntPtr.Zero; + try { buf = Marshal.AllocHGlobal (8192); if (uname (buf) == 0 && Marshal.PtrToStringAnsi (buf) == "Darwin") return PlatformID.MacOSX; + } catch { } finally { if (buf != IntPtr.Zero)