[longomatch] Add a helper function to properly detect OSX.
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [longomatch] Add a helper function to properly detect OSX.
- Date: Mon, 27 Apr 2015 22:21:27 +0000 (UTC)
commit cd5c900dd522001ada3705d9936e60a54c9c2298
Author: Josep Torra <n770galaxy gmail com>
Date: Fri Apr 24 13:11:31 2015 +0200
Add a helper function to properly detect OSX.
LongoMatch.Core/Common/Utils.cs | 27 +++++++++++++++++++++++----
1 files changed, 23 insertions(+), 4 deletions(-)
---
diff --git a/LongoMatch.Core/Common/Utils.cs b/LongoMatch.Core/Common/Utils.cs
index f06ffcb..5c4dc5c 100644
--- a/LongoMatch.Core/Common/Utils.cs
+++ b/LongoMatch.Core/Common/Utils.cs
@@ -22,17 +22,36 @@ namespace LongoMatch.Core.Common
{
public class Utils
{
- public static string SanitizePath(string path, params char[] replaceChars)
+ static int currentPlatformID = -1;
+
+ public static string SanitizePath (string path, params char[] replaceChars)
{
- path = path.Trim();
+ path = path.Trim ();
foreach (char c in Path.GetInvalidFileNameChars ()) {
- path = path.Replace(c, '_');
+ path = path.Replace (c, '_');
}
foreach (char c in replaceChars) {
- path = path.Replace(c, '_');
+ path = path.Replace (c, '_');
}
return path;
}
+
+ public static PlatformID RunningPlatform ()
+ {
+ if (currentPlatformID == -1) {
+ currentPlatformID = (int)Environment.OSVersion.Platform;
+
+ if (currentPlatformID == (int)PlatformID.Unix) {
+ if (Directory.Exists ("/Applications")
+ & Directory.Exists ("/System")
+ & Directory.Exists ("/Users")
+ & Directory.Exists ("/Volumes")) {
+ currentPlatformID = (int)PlatformID.MacOSX;
+ }
+ }
+ }
+ return (PlatformID)currentPlatformID;
+ }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]