[chronojump] Better MacOSX identification
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Better MacOSX identification
- Date: Mon, 16 Mar 2015 14:15:19 +0000 (UTC)
commit b8599cf5162d1abe6b607259401bd70e8f8416bb
Author: Xavier de Blas <xaviblas gmail com>
Date: Mon Mar 16 15:13:44 2015 +0100
Better MacOSX identification
src/utilAll.cs | 27 ++++++++++++++++++++-------
1 files changed, 20 insertions(+), 7 deletions(-)
---
diff --git a/src/utilAll.cs b/src/utilAll.cs
index e514c3c..cf8b3bc 100644
--- a/src/utilAll.cs
+++ b/src/utilAll.cs
@@ -58,13 +58,26 @@ public class UtilAll
public static OperatingSystems GetOSEnum()
{
- string os = GetOS();
- if(os.ToUpper().StartsWith("WIN"))
- return OperatingSystems.WINDOWS;
- else if(os.ToUpper().StartsWith("MAC"))
- return OperatingSystems.MACOSX;
- else
- return OperatingSystems.LINUX;
+
//http://stackoverflow.com/questions/10138040/how-to-detect-properly-windows-linux-mac-operating-systems
+ switch (Environment.OSVersion.Platform)
+ {
+ case PlatformID.Unix:
+ // Well, there are chances MacOSX is reported as Unix instead of MacOSX.
+ // Instead of platform check, we'll do a feature checks (Mac specific root
folders)
+ if (Directory.Exists("/Applications")
+ & Directory.Exists("/System")
+ & Directory.Exists("/Users")
+ & Directory.Exists("/Volumes"))
+ return OperatingSystems.MACOSX;
+ else
+ return OperatingSystems.LINUX;
+
+ case PlatformID.MacOSX:
+ return OperatingSystems.MACOSX;
+
+ default:
+ return OperatingSystems.WINDOWS;
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]