In the end, I used the library Korio. The documentation could be better, but all of the functionality I need is implemented for all platforms (Jvm, Desktop, Android, ..):
import com.soywiz.korio.file.std.*
suspend fun main {
val cwd = localCurrentDirVfs
val files = cwd.list()
cwd["Hello.txt"].open().close()
cwd["Hello.txt"].renameTo("Hi.txt")
val metadata = cwd["Hi.txt"].stat()
}
On top of that, it allows usage of the same API for accessing online files, zip archives, etc. which is pretty neat.
Answer from Ford O. on Stack OverflowIn the end, I used the library Korio. The documentation could be better, but all of the functionality I need is implemented for all platforms (Jvm, Desktop, Android, ..):
import com.soywiz.korio.file.std.*
suspend fun main {
val cwd = localCurrentDirVfs
val files = cwd.list()
cwd["Hello.txt"].open().close()
cwd["Hello.txt"].renameTo("Hi.txt")
val metadata = cwd["Hi.txt"].stat()
}
On top of that, it allows usage of the same API for accessing online files, zip archives, etc. which is pretty neat.
You might want to look at OKIO. There is some multiplatform support, and a Windows target, but I don't know first hand if the filesystem portion is implemented on Windows: https://github.com/square/okio
By default, Kotlin/native does not come with file based IO similar to java.io or java.nio, but allows C functions from the platform.posix.* package. Is there some open source library available for provide similar API like java.nio which internally uses, but hides the use of platform.posix from teh library user? Is Jetbrains planning to do something like that?