Add prop OSTailoredCode.IsWSL
This commit is contained in:
parent
cb6f435f9a
commit
ec80d0fb1d
|
@ -5,6 +5,9 @@ namespace BizHawk.Common.StringExtensions
|
||||||
{
|
{
|
||||||
public static class StringExtensions
|
public static class StringExtensions
|
||||||
{
|
{
|
||||||
|
public static bool Contains(this string haystack, string needle, StringComparison comparisonType)
|
||||||
|
=> haystack.IndexOf(needle, comparisonType) != -1;
|
||||||
|
|
||||||
/// <returns>
|
/// <returns>
|
||||||
/// <see langword="true"/> if <paramref name="str"/> appears in <paramref name="options"/> (case-insensitive)
|
/// <see langword="true"/> if <paramref name="str"/> appears in <paramref name="options"/> (case-insensitive)
|
||||||
/// </returns>
|
/// </returns>
|
||||||
|
|
|
@ -3,6 +3,8 @@ using System.Diagnostics;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
using BizHawk.Common.StringExtensions;
|
||||||
|
|
||||||
#if EXE_PROJECT
|
#if EXE_PROJECT
|
||||||
namespace EXE_PROJECT // Use a different namespace so the executable can still use this class' members without an implicit dependency on the BizHawk.Common library, and without resorting to code duplication.
|
namespace EXE_PROJECT // Use a different namespace so the executable can still use this class' members without an implicit dependency on the BizHawk.Common library, and without resorting to code duplication.
|
||||||
#else
|
#else
|
||||||
|
@ -44,10 +46,14 @@ namespace BizHawk.Common
|
||||||
return (winVer, null);
|
return (winVer, null);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
private static readonly Lazy<bool> _isWSL = new(() => IsUnixHost && SimpleSubshell("uname", "-r", "missing uname?").Contains("microsoft", StringComparison.InvariantCultureIgnoreCase));
|
||||||
|
|
||||||
public static (WindowsVersion Version, int? Win10Release)? HostWindowsVersion => _HostWindowsVersion.Value;
|
public static (WindowsVersion Version, int? Win10Release)? HostWindowsVersion => _HostWindowsVersion.Value;
|
||||||
|
|
||||||
public static readonly bool IsUnixHost = CurrentOS != DistinctOS.Windows;
|
public static readonly bool IsUnixHost = CurrentOS != DistinctOS.Windows;
|
||||||
|
|
||||||
|
public static bool IsWSL => _isWSL.Value;
|
||||||
|
|
||||||
private static readonly Lazy<ILinkedLibManager> _LinkedLibManager = new Lazy<ILinkedLibManager>(() => CurrentOS switch
|
private static readonly Lazy<ILinkedLibManager> _LinkedLibManager = new Lazy<ILinkedLibManager>(() => CurrentOS switch
|
||||||
{
|
{
|
||||||
DistinctOS.Linux => new UnixMonoLLManager(),
|
DistinctOS.Linux => new UnixMonoLLManager(),
|
||||||
|
|
Loading…
Reference in New Issue