2019-12-10 20:20:45 +01:00
|
|
|
|
using System;
|
2019-12-09 17:25:54 +01:00
|
|
|
|
using System.IO;
|
|
|
|
|
|
|
|
|
|
namespace Swan {
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Provides utility methods to retrieve information about the current application.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static class SwanRuntime {
|
2019-12-10 20:01:19 +01:00
|
|
|
|
// [Obsolete("NEED", false)]
|
2019-12-09 17:25:54 +01:00
|
|
|
|
private static OperatingSystem? _oS;
|
|
|
|
|
|
2019-12-10 20:01:19 +01:00
|
|
|
|
#region Properties
|
2019-12-09 17:25:54 +01:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the current Operating System.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>
|
|
|
|
|
/// The os.
|
|
|
|
|
/// </value>
|
2019-12-10 20:01:19 +01:00
|
|
|
|
// [Obsolete("NEED", false)]
|
2019-12-09 17:25:54 +01:00
|
|
|
|
public static OperatingSystem OS {
|
|
|
|
|
get {
|
|
|
|
|
if(_oS.HasValue == false) {
|
|
|
|
|
String windowsDirectory = Environment.GetEnvironmentVariable("windir");
|
|
|
|
|
_oS = String.IsNullOrEmpty(windowsDirectory) == false && windowsDirectory.Contains(@"\") && Directory.Exists(windowsDirectory)
|
|
|
|
|
? (OperatingSystem?)OperatingSystem.Windows
|
|
|
|
|
: (OperatingSystem?)(File.Exists(@"/proc/sys/kernel/ostype") ? OperatingSystem.Unix : OperatingSystem.Osx);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return _oS ?? OperatingSystem.Unknown;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|