code optimization

This commit is contained in:
2024-06-05 19:15:32 +02:00
parent d4be7d0566
commit 1b49c54822
151 changed files with 4124 additions and 4673 deletions

View File

@@ -26,56 +26,56 @@ Namespace Runtime
End Get
End Property
Public ReadOnly Property RealOSType As OSType
Get
Static t As OSType? = Nothing
Public ReadOnly Property RealOSType As OSType
Get
Static t As OSType? = Nothing
If t Is Nothing Then
If t Is Nothing Then
Dim windir = Environment.GetEnvironmentVariable("windir")
Const ostypeDirWine = "Z:\proc\sys\kernel\ostype"
Const ostypeDirNative = "/proc/sys/kernel/ostype"
Const systemVersionWine = "Z:\System\Library\CoreServices\SystemVersion.plist"
Const systemVersionNative = "/System/Library/CoreServices/SystemVersion.plist"
Dim windir = Environment.GetEnvironmentVariable("windir")
Const ostypeDirWine = "Z:\proc\sys\kernel\ostype"
Const ostypeDirNative = "/proc/sys/kernel/ostype"
Const systemVersionWine = "Z:\System\Library\CoreServices\SystemVersion.plist"
Const systemVersionNative = "/System/Library/CoreServices/SystemVersion.plist"
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
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
End If
Return t
End Get
End Property
Return t
End Get
End Property
Public Function IsOSPlatform(os As OSType, checkRealOS As Boolean) As Boolean
Return If(checkRealOS, RealOSType, OSType) = os
End Function
Public Function IsOSPlatform(os As OSType, checkRealOS As Boolean) As Boolean
Return If(checkRealOS, RealOSType, OSType) = os
End Function
End Module
End Module
End Namespace