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 042527c..d66e646 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 @@ -139,34 +139,43 @@ class FileAccess { * Updates all default paths to * their platform-specific path. * + * @throws VerificationFailedException if path creation fails * @since v1-alpha10 */ + @Throws(VerificationFailedException::class) internal fun updateDefaultPaths() { logger.diag("Updating default paths") + // Storage - homeDirectory = FileAccess(System.getProperty("user.home")).createDirectory() + homeDirectory = FileAccess(System.getProperty("user.home")) + .createDirectory().verifyIsDirectory() + configDirectory = FileAccess(when (Environment.operatingSystem) { LINUX, FREEBSD, NETBSD, OPENBSD -> "${homeDirectory}/.config" WINDOWS -> "${homeDirectory}/AppData/Roaming/sosengine-config" else -> "${homeDirectory}/.sosengine/config" - }).createDirectory() + }).createDirectory().verifyIsDirectory() + dataDirectory = FileAccess(when (Environment.operatingSystem) { LINUX, FREEBSD, NETBSD, OPENBSD -> "${homeDirectory}/.local/share" WINDOWS -> "${homeDirectory}/AppData/Roaming/sosengine-data" else -> "${homeDirectory}/.sosengine/data" - }).createDirectory() + }).createDirectory().verifyIsDirectory() + + // Caches temporaryCacheDirectory = FileAccess( System.getProperty("java.io.tmpdir") + "/sosengine-cache-" + ProcessHandle.current().pid() - ).createDirectory().deleteOnShutdown() + ).createDirectory().verifyIsDirectory().deleteOnShutdown() + persistentCacheDirectory = FileAccess(when (Environment.operatingSystem) { LINUX, FREEBSD, NETBSD, OPENBSD -> "${homeDirectory}/.cache" WINDOWS -> "${homeDirectory}/AppData/Local/Temp" else -> "${homeDirectory}/.sosengine/persistent-cache" - }).createDirectory() + }).createDirectory().verifyIsDirectory() }