update RealOSType check
This commit is contained in:
@@ -30,28 +30,45 @@ Namespace Runtime
|
|||||||
Get
|
Get
|
||||||
Static t As OSType? = Nothing
|
Static t As OSType? = Nothing
|
||||||
|
|
||||||
If t Is Nothing Then
|
If t Is Nothing Then
|
||||||
Dim windir As String = Environment.GetEnvironmentVariable("windir")
|
|
||||||
|
|
||||||
If Not String.IsNullOrEmpty(windir) AndAlso windir.Contains("\") AndAlso Directory.Exists(windir) Then
|
Dim windir = Environment.GetEnvironmentVariable("windir")
|
||||||
t = OSType.Windows
|
Dim ostypeDirWine = "Z:\proc\sys\kernel\ostype"
|
||||||
ElseIf File.Exists("/proc/sys/kernel/ostype") Then
|
Dim ostypeDirNative = "/proc/sys/kernel/ostype"
|
||||||
Dim osTypeString As String = File.ReadAllText("/proc/sys/kernel/ostype")
|
Dim systemVersionWine = "Z:\System\Library\CoreServices\SystemVersion.plist"
|
||||||
If osTypeString.StartsWith("Linux", StringComparison.OrdinalIgnoreCase) Then
|
Dim systemVersionNative = "/System/Library/CoreServices/SystemVersion.plist"
|
||||||
' Note: Android gets here too
|
|
||||||
t = OSType.Linux
|
|
||||||
Else
|
|
||||||
t = OSType.Unknown
|
|
||||||
End If
|
|
||||||
ElseIf File.Exists("/System/Library/CoreServices/SystemVersion.plist") Then
|
|
||||||
' Note: iOS gets here too
|
|
||||||
t = OSType.OSX
|
|
||||||
Else
|
|
||||||
t = OSType.Unknown
|
|
||||||
End If
|
|
||||||
End If
|
|
||||||
|
|
||||||
Return t
|
If File.Exists(ostypeDirWine) Then ' Linux using wine
|
||||||
|
Dim osTypeString As String = File.ReadAllText(ostypeDirWine)
|
||||||
|
If osTypeString.StartsWith("Linux", StringComparison.OrdinalIgnoreCase) Then
|
||||||
|
' Note: Android gets here too
|
||||||
|
t = OSType.Linux
|
||||||
|
Else
|
||||||
|
t = OSType.Unknown
|
||||||
|
End If
|
||||||
|
ElseIf File.Exists(ostypeDirNative) Then ' Linux native
|
||||||
|
Dim osTypeString As String = File.ReadAllText(ostypeDirNative)
|
||||||
|
If osTypeString.StartsWith("Linux", StringComparison.OrdinalIgnoreCase) Then
|
||||||
|
' Note: Android gets here too
|
||||||
|
t = OSType.Linux
|
||||||
|
Else
|
||||||
|
t = OSType.Unknown
|
||||||
|
End If
|
||||||
|
ElseIf File.Exists(systemVersionWine) Then ' OSX using wine
|
||||||
|
' Note: iOS gets here too
|
||||||
|
t = OSType.OSX
|
||||||
|
ElseIf File.Exists(systemVersionNative) Then ' OSX native
|
||||||
|
' Note: iOS gets here too
|
||||||
|
t = OSType.OSX
|
||||||
|
ElseIf Not String.IsNullOrEmpty(windir) AndAlso Directory.Exists(windir) AndAlso Path.DirectorySeparatorChar = "\"c Then ' Windows
|
||||||
|
t = OSType.Windows
|
||||||
|
Else
|
||||||
|
t = OSType.Unknown
|
||||||
|
End If
|
||||||
|
|
||||||
|
End If
|
||||||
|
|
||||||
|
Return t
|
||||||
End Get
|
End Get
|
||||||
End Property
|
End Property
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user