2016-11-04 12:51:59 -07:00
|
|
|
|
using System;
|
2017-04-08 11:31:18 -07:00
|
|
|
|
using System.IO;
|
2016-11-04 12:51:59 -07:00
|
|
|
|
using MediaBrowser.Model.System;
|
|
|
|
|
|
2017-08-15 23:43:41 -07:00
|
|
|
|
namespace Emby.Server.Implementations.EnvironmentInfo
|
2016-11-04 12:51:59 -07:00
|
|
|
|
{
|
|
|
|
|
public class EnvironmentInfo : IEnvironmentInfo
|
|
|
|
|
{
|
2017-08-17 13:19:02 -07:00
|
|
|
|
private Architecture? _customArchitecture;
|
|
|
|
|
private MediaBrowser.Model.System.OperatingSystem? _customOperatingSystem;
|
2016-11-11 01:13:11 -07:00
|
|
|
|
|
2017-02-07 01:23:45 -07:00
|
|
|
|
public virtual MediaBrowser.Model.System.OperatingSystem OperatingSystem
|
2016-11-04 12:51:59 -07:00
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2017-08-17 13:19:02 -07:00
|
|
|
|
if (_customOperatingSystem.HasValue)
|
2016-12-21 21:47:59 -07:00
|
|
|
|
{
|
2017-08-17 13:19:02 -07:00
|
|
|
|
return _customOperatingSystem.Value;
|
2016-12-21 21:47:59 -07:00
|
|
|
|
}
|
|
|
|
|
|
2017-04-29 10:30:28 -07:00
|
|
|
|
switch (Environment.OSVersion.Platform)
|
|
|
|
|
{
|
|
|
|
|
case PlatformID.MacOSX:
|
|
|
|
|
return MediaBrowser.Model.System.OperatingSystem.OSX;
|
|
|
|
|
case PlatformID.Win32NT:
|
|
|
|
|
return MediaBrowser.Model.System.OperatingSystem.Windows;
|
|
|
|
|
case PlatformID.Unix:
|
|
|
|
|
return MediaBrowser.Model.System.OperatingSystem.Linux;
|
|
|
|
|
}
|
2017-05-24 12:12:55 -07:00
|
|
|
|
|
2016-11-04 12:51:59 -07:00
|
|
|
|
return MediaBrowser.Model.System.OperatingSystem.Windows;
|
|
|
|
|
}
|
2017-08-17 13:19:02 -07:00
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_customOperatingSystem = value;
|
|
|
|
|
}
|
2016-11-04 12:51:59 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string OperatingSystemName
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2017-04-29 10:30:28 -07:00
|
|
|
|
return Environment.OSVersion.Platform.ToString();
|
2016-11-04 12:51:59 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string OperatingSystemVersion
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2017-04-29 10:30:28 -07:00
|
|
|
|
return Environment.OSVersion.Version.ToString() + " " + Environment.OSVersion.ServicePack.ToString();
|
2016-11-04 12:51:59 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
2016-11-11 01:13:11 -07:00
|
|
|
|
|
2017-04-08 11:31:18 -07:00
|
|
|
|
public char PathSeparator
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return Path.PathSeparator;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-24 12:12:55 -07:00
|
|
|
|
public Architecture SystemArchitecture
|
2016-11-11 01:13:11 -07:00
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2017-08-17 13:19:02 -07:00
|
|
|
|
if (_customArchitecture.HasValue)
|
2016-11-11 01:13:11 -07:00
|
|
|
|
{
|
2017-08-17 13:19:02 -07:00
|
|
|
|
return _customArchitecture.Value;
|
2016-11-11 01:13:11 -07:00
|
|
|
|
}
|
2017-05-24 12:12:55 -07:00
|
|
|
|
|
2017-04-29 10:30:28 -07:00
|
|
|
|
return Environment.Is64BitOperatingSystem ? MediaBrowser.Model.System.Architecture.X64 : MediaBrowser.Model.System.Architecture.X86;
|
2016-11-11 01:13:11 -07:00
|
|
|
|
}
|
2017-08-17 13:19:02 -07:00
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_customArchitecture = value;
|
|
|
|
|
}
|
2016-11-11 01:13:11 -07:00
|
|
|
|
}
|
2016-11-13 14:04:21 -07:00
|
|
|
|
|
|
|
|
|
public string GetEnvironmentVariable(string name)
|
|
|
|
|
{
|
|
|
|
|
return Environment.GetEnvironmentVariable(name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual string GetUserId()
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2016-11-21 01:54:53 -07:00
|
|
|
|
|
|
|
|
|
public string StackTrace
|
|
|
|
|
{
|
|
|
|
|
get { return Environment.StackTrace; }
|
|
|
|
|
}
|
2016-11-29 12:13:20 -07:00
|
|
|
|
|
|
|
|
|
public void SetProcessEnvironmentVariable(string name, string value)
|
|
|
|
|
{
|
|
|
|
|
Environment.SetEnvironmentVariable(name, value);
|
|
|
|
|
}
|
2016-11-04 12:51:59 -07:00
|
|
|
|
}
|
2017-04-29 10:30:28 -07:00
|
|
|
|
}
|