aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/utils/OSUtils.kt
diff options
context:
space:
mode:
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