package eu.friedcutlet.yokan.services.files import eu.friedcutlet.yokan.AndroidAppContext actual fun createPlatformLocalArchiveService(profileId: eu.friedcutlet.yokan.domain.ProfileId): LocalArchiveService = AndroidSafLocalArchiveService( cacheRoot = createPlatformLocalFileService(profileId).cacheRoot, ) actual fun createPlatformLocalFileService(profileId: eu.friedcutlet.yokan.domain.ProfileId): LocalFileService { val context = AndroidAppContext.appContext val namespace = eu.friedcutlet.yokan.domain.ProfileStorageNamespace(profileId) if (profileId != eu.friedcutlet.yokan.domain.ProfileId.Default) checkNotNull(context) { "Android context unavailable" } val filesDir = context?.filesDir?.absolutePath ?: System.getProperty("java.io.tmpdir").orEmpty() return AndroidSafLocalFileService( JvmLocalFileService( downloadRoot = "${namespace.ownedRoot(filesDir)}/downloads", backupRoot = "${namespace.ownedRoot(filesDir)}/backups", cacheRoot = if (namespace.relativeRoot == null) context?.cacheDir?.absolutePath ?: "$filesDir/cache" else "${namespace.ownedRoot(checkNotNull(context).cacheDir.absolutePath)}/cache", openDirectory = ::openAndroidDirectory, ), ) }