And how do you do File/IO in K/Native?
# kotlin-native
a
And how do you do File/IO in K/Native?
a
@Kris Wong none of them seems to target native 😞
k
iOS is native
if you are looking for other targets, then you will most likely have to roll your own APIs
a
https://github.com/Kotlin/kotlinx-io seems like this has future plans for Files IO
g
The most reliable and multiplatform (native) way is use posix api for files But I'm not aware about ready to use wrappers for this
👍 1
n
Sure iOS is native but Kotlin Native targets other platforms like Linux 🐧 for example. Kotlin Native isn't all about 🍎 platforms.
👍 1
On Unix based platforms (eg Linux) it is recommended to use the POSIX APIs like @gildor has mentioned. Start with the FILE series of APIs from POSIX like fopen, fclose, fwrite, fread etc.
💯 2
s
☝️ 1
👍 1
g
It’s still quite big pain that there is no single file API for K/N targets
k
IMO there are much bigger pains than that
👍 1
but I'm a mobile developer and we don't use files directly all that often
g
I’m a mobile developer and I use files every day, it one of the biggest parts of our business logic.
v
I've been trying to use the POSIX file APIs, but am completely lost - sizeOf() doesn't return a size_t so I cannot work out how to use fwrite(). Pretty disappointed that file IO isn't a priority for K/N.
👀 1
g
Could you share the code? There are examples in K/N repo