aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/utils/OSUtils.kt
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal002@users.noreply.github.com>2024-10-07 13:33:51 +0200
committerGitHub <noreply@github.com>2024-10-07 13:33:51 +0200
commitf53fbddd604fd795780f16c25f57378c32d18763 (patch)
tree31e9f2f20f1b5b0c72c36892af49a89c08c5b784 /src/main/java/at/hannibal2/skyhanni/utils/OSUtils.kt
parent266d007da9f23b19f8e815da3005451195a33a5e (diff)
downloadskyhanni-f53fbddd604fd795780f16c25f57378c32d18763.tar.gz
skyhanni-f53fbddd604fd795780f16c25f57378c32d18763.tar.bz2
skyhanni-f53fbddd604fd795780f16c25f57378c32d18763.zip
Backend: More /shdebug (#2691)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Co-authored-by: CalMWolfs <94038482+CalMWolfs@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils/OSUtils.kt')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/OSUtils.kt30
1 files changed, 26 insertions, 4 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/OSUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/OSUtils.kt
index 5b42c5dc6..ecd0f0650 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/OSUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/OSUtils.kt
@@ -7,15 +7,37 @@ import java.net.URI
object OSUtils {
+ enum class OperatingSystem {
+ LINUX,
+ SOLARIS,
+ WINDOWS,
+ MACOS,
+ UNKNOWN,
+ }
+
+ fun getOperatingSystemRaw(): String = System.getProperty("os.name")
+
+ fun getOperatingSystem(): OperatingSystem {
+ val osName = getOperatingSystemRaw().lowercase()
+ return when {
+ osName.contains("win") -> OperatingSystem.WINDOWS
+ osName.contains("mac") -> OperatingSystem.MACOS
+ osName.contains("solaris") || osName.contains("sunos") -> OperatingSystem.SOLARIS
+ osName.contains("linux") || osName.contains("unix") -> OperatingSystem.LINUX
+
+ else -> OperatingSystem.UNKNOWN
+ }
+ }
+
val isWindows: Boolean
val isMac: Boolean
val isLinux: Boolean
init {
- val os = System.getProperty("os.name")
- isWindows = os.contains("win", ignoreCase = true)
- isMac = os.contains("mac", ignoreCase = true)
- isLinux = os.contains("linux", ignoreCase = true)
+ val os = getOperatingSystem()
+ isWindows = os == OperatingSystem.WINDOWS
+ isMac = os == OperatingSystem.MACOS
+ isLinux = os == OperatingSystem.LINUX
}
@JvmStatic