Skip to content

Stores on desktop targets requires the folder to be created ahead of file writes/reads #103

Description

@xxfast

Creating a store for android/ios is fairly straightforward

//android
val filesDir: String = androidContext().filesDir.path
storeOf(file = "$filesDir/countries.json".toPath(), default = emptyList())
        
// ios
val filesDir: String? = NSFileManager.defaultManager.DocumentDirectory?.relativePath
requireNotNull(filesDir) { "Document directory not found" }
storeOf(file = "$filesDir/countries.json".toPath(), default = emptyList())

However, for desktop we need this extra step

// desktop
val filesDir: String = AppDirsFactory.getInstance()
            .getUserDataDir(PACKAGE_NAME, VERSION, AUTHOR)

FILE_SYSTEM.createDirectories(filesDir.toPath())

storeOf(file = "$filesDir/countries.json".toPath(), default = emptyList())

Need to think of an API to bridge this gap

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions