Is there a Kotlin Multiplatform library to work wi...
# multiplatform
j
Is there a Kotlin Multiplatform library to work with files? a simple wrapper to
java.util.File
on the JVM and POSIX calls on Kotlin native
fopen
,
fclose
,
acccess
, ...
e
https://github.com/Kotlin/kotlinx-io - largely not ready yet
j
okio
1
a
For basic File reading and writing on K/N, I use the functions described in this post: https://nequalsonelifestyle.com/2020/11/16/kotlin-native-file-io/
👍 1
f
@apahl Do you use the functions on iOS too? How do you pass the filePath parameter?
a
No, I use K/N only on Linux.
👍 1
n
Mobile platforms like Android, and iOS don't allow direct file access for security reasons (revolves around sand boxing).
On Linux there is direct file access. This also applies to Flatpak ( https://flatpak.org/ ) although that is subject to sandbox restrictions and what file access permissions an app has in its manifest. Some Linux distributions like Linux Mint, and Fedora already support Flatpak, and provide the traditional app distribution method (deb, rpm etc).
If Linux is being targeted, and a GTK based application is being developed then the GIO ( https://developer.gnome.org/gio/stable/ ) library might be an option (is an alternative the the POSIX File IO APIs).