Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/duplicati/duplicati.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorverhoek <30193551+verhoek@users.noreply.github.com>2018-11-03 00:19:03 +0300
committerverhoek <30193551+verhoek@users.noreply.github.com>2018-11-03 00:25:44 +0300
commit317198816fb190a58cad7201797a40e5ca420db7 (patch)
tree5e7a0d669c6af2ef99b37259aec64111702162ee /Duplicati/Library/Common/Platform
parent8bb406cd15406771c71a2ca8ec0f0a9163e2ca9b (diff)
Moving from IO to Common dir.
Diffstat (limited to 'Duplicati/Library/Common/Platform')
-rw-r--r--Duplicati/Library/Common/Platform/Platform.cs108
1 files changed, 108 insertions, 0 deletions
diff --git a/Duplicati/Library/Common/Platform/Platform.cs b/Duplicati/Library/Common/Platform/Platform.cs
new file mode 100644
index 000000000..1cfb1b987
--- /dev/null
+++ b/Duplicati/Library/Common/Platform/Platform.cs
@@ -0,0 +1,108 @@
+// Copyright (C) 2018, The Duplicati Team
+// http://www.duplicati.com, info@duplicati.com
+//
+// This library is free software; you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as
+// published by the Free Software Foundation; either version 2.1 of the
+// License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+using System;
+namespace Duplicati.Library.Common
+{
+ public static class Platform
+ {
+ /// <value>
+ /// Gets or sets a value indicating if the client is Linux/Unix based
+ /// </value>
+ public static bool IsClientLinux => Environment.OSVersion.Platform == PlatformID.Unix || Environment.OSVersion.Platform == PlatformID.MacOSX;
+
+ /// <summary>
+ /// Gets a value indicating if the client is Windows based
+ /// </summary>
+ public static bool IsClientWindows => !IsClientLinux;
+
+
+ private static string UNAME;
+
+ /// <value>
+ /// Gets or sets a value indicating if the client is running OSX
+ /// </value>
+ public static bool IsClientOSX
+ {
+ get
+ {
+ // Sadly, Mono returns Unix when running on OSX
+ //return Environment.OSVersion.Platform == PlatformID.MacOSX;
+
+ if (!IsClientLinux)
+ return false;
+
+ try
+ {
+ if (UNAME == null)
+ {
+ var psi = new System.Diagnostics.ProcessStartInfo("uname")
+ {
+ RedirectStandardOutput = true,
+ RedirectStandardInput = false,
+ RedirectStandardError = false,
+ UseShellExecute = false
+ };
+
+ var pi = System.Diagnostics.Process.Start(psi);
+ pi.WaitForExit(5000);
+ if (pi.HasExited)
+ UNAME = pi.StandardOutput.ReadToEnd().Trim();
+ }
+ }
+ catch
+ {
+ }
+
+ return "Darwin".Equals(UNAME);
+
+ }
+ }
+ /// <value>
+ /// Gets the output of "uname -a" on Linux, or null on Windows
+ /// </value>
+ public static string UnameAll
+ {
+ get
+ {
+ if (!IsClientLinux)
+ return null;
+
+ try
+ {
+ var psi = new System.Diagnostics.ProcessStartInfo("uname", "-a")
+ {
+ RedirectStandardOutput = true,
+ RedirectStandardError = false,
+ RedirectStandardInput = false,
+ UseShellExecute = false
+ };
+
+ var pi = System.Diagnostics.Process.Start(psi);
+ pi.WaitForExit(5000);
+ if (pi.HasExited)
+ return pi.StandardOutput.ReadToEnd().Trim();
+ }
+ catch
+ {
+ // ignored
+ }
+
+ return null;
+ }
+ }
+ }
+}