diff --git a/base/src/main/kotlin/de/staropensource/engine/base/utility/Environment.kt b/base/src/main/kotlin/de/staropensource/engine/base/utility/Environment.kt index cef6844..122a806 100644 --- a/base/src/main/kotlin/de/staropensource/engine/base/utility/Environment.kt +++ b/base/src/main/kotlin/de/staropensource/engine/base/utility/Environment.kt @@ -21,11 +21,7 @@ package de.staropensource.engine.base.utility import de.staropensource.engine.base.Engine.Companion.logger -import de.staropensource.engine.base.utility.Environment.OperatingSystem.FREEBSD -import de.staropensource.engine.base.utility.Environment.OperatingSystem.LINUX -import de.staropensource.engine.base.utility.Environment.OperatingSystem.NETBSD -import de.staropensource.engine.base.utility.Environment.OperatingSystem.OPENBSD -import de.staropensource.engine.base.utility.Environment.OperatingSystem.WINDOWS +import de.staropensource.engine.base.utility.Environment.OperatingSystem.* import oshi.PlatformEnum import oshi.SystemInfo @@ -80,6 +76,7 @@ class Environment private constructor() { PlatformEnum.OPENBSD -> operatingSystem = OPENBSD //PlatformEnum.ANDROID -> Environment.operatingSystem = Environment.OperatingSystem.ANDROID // android is not yet supported by the engine, have to figure that one out sometime PlatformEnum.WINDOWS, PlatformEnum.WINDOWSCE -> operatingSystem = WINDOWS + PlatformEnum.MACOS -> operatingSystem = MACOS else -> logger.crash("Unsupported operating system '" + os.family + "'") } } @@ -154,5 +151,14 @@ class Environment private constructor() { * @since v1-alpha10 */ WINDOWS, + + /** + * Identifies that the application is running + * under [macOS](https://apple.com/macos), and + * by extension under the [XNU kernel](https://github.com/apple-oss-distributions/xnu). + * + * @since v1-alpha10 + */ + MACOS, } } diff --git a/base/src/main/kotlin/de/staropensource/engine/base/utility/FileAccess.kt b/base/src/main/kotlin/de/staropensource/engine/base/utility/FileAccess.kt index 224b038..53711fc 100644 --- a/base/src/main/kotlin/de/staropensource/engine/base/utility/FileAccess.kt +++ b/base/src/main/kotlin/de/staropensource/engine/base/utility/FileAccess.kt @@ -149,17 +149,20 @@ class FileAccess { // Storage homeDirectory = FileAccess(System.getProperty("user.home")) - .createDirectory().verifyIsDirectory() + .createDirectory() + .verifyIsDirectory() configDirectory = FileAccess(when (Environment.operatingSystem) { LINUX, FREEBSD, NETBSD, OPENBSD -> "${homeDirectory}/.config" - WINDOWS -> "${homeDirectory}/AppData/Roaming/sosengine-config" + WINDOWS -> "${homeDirectory}/AppData/Roaming/sosengine/config" + MACOS -> "${homeDirectory}/Library/Application Support/sosengine/config" else -> "${homeDirectory}/.sosengine/config" }).createDirectory().verifyIsDirectory() dataDirectory = FileAccess(when (Environment.operatingSystem) { LINUX, FREEBSD, NETBSD, OPENBSD -> "${homeDirectory}/.local/share" - WINDOWS -> "${homeDirectory}/AppData/Roaming/sosengine-data" + WINDOWS -> "${homeDirectory}/AppData/Roaming/sosengine/data" + MACOS -> "${homeDirectory}/Library/Application Support/sosengine/data" else -> "${homeDirectory}/.sosengine/data" }).createDirectory().verifyIsDirectory() @@ -174,6 +177,7 @@ class FileAccess { persistentCacheDirectory = FileAccess(when (Environment.operatingSystem) { LINUX, FREEBSD, NETBSD, OPENBSD -> "${homeDirectory}/.cache" WINDOWS -> "${homeDirectory}/AppData/Local/Temp" + MACOS -> "${homeDirectory}/Library/Caches" else -> "${homeDirectory}/.sosengine/persistent-cache" }).createDirectory().verifyIsDirectory() }