https://kotlinlang.org logo
j

jmfayard

05/03/2021, 1:00 PM
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

ephemient

05/03/2021, 1:03 PM
https://github.com/Kotlin/kotlinx-io - largely not ready yet
j

Javier

05/03/2021, 1:15 PM
okio
1
a

apahl

05/03/2021, 1:28 PM
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

Francis Mariano

05/03/2021, 2:34 PM
@apahl Do you use the functions on iOS too? How do you pass the filePath parameter?
a

apahl

05/03/2021, 2:43 PM
No, I use K/N only on Linux.
👍 1
n

napperley

06/13/2021, 10:39 PM
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).