Yokan / rebuild
Course 1 8624561

LocalFileService.desktop.kt

composeApp/src/desktopMain/kotlin/eu/friedcutlet/yokan/services/files/LocalFileService.desktop.kt

implementation29 lines
1package eu.friedcutlet.yokan.services.files23import java.awt.Desktop4import java.io.File56actual fun createPlatformLocalArchiveService(profileId: eu.friedcutlet.yokan.domain.ProfileId): LocalArchiveService = JvmLocalArchiveService(7    cacheRoot = createPlatformLocalFileService(profileId).cacheRoot,8)910actual fun createPlatformLocalFileService(profileId: eu.friedcutlet.yokan.domain.ProfileId): LocalFileService =11    createDesktopProfileFileService(desktopDataRoot, profileId, ::openInDesktopShell)1213internal fun createDesktopProfileFileService(dataRoot: File, profileId: eu.friedcutlet.yokan.domain.ProfileId,14    openDirectory: (File) -> Boolean = { false }): LocalFileService {15    val namespace = eu.friedcutlet.yokan.domain.ProfileStorageNamespace(profileId)16    val root = File(namespace.ownedRoot(dataRoot.path))17    return JvmLocalFileService(18        downloadRoot = File(root, if (namespace.relativeRoot == null) "Yokan/downloads" else "downloads").path,19        backupRoot = File(root, if (namespace.relativeRoot == null) "Yokan/backups" else "backups").path,20        cacheRoot = File(root, "cache").path,21        openDirectory = openDirectory,22    )23}2425private fun openInDesktopShell(directory: File): Boolean {26    if (!Desktop.isDesktopSupported() || !Desktop.getDesktop().isSupported(Desktop.Action.OPEN)) return false27    Desktop.getDesktop().open(directory)28    return true29}30

Search chapters, reference and source filenames.