I have pushed the initial code for the KFile proje...
# multiplatform
p
I have pushed the initial code for the KFile project, my attempt to provide a library that provides a canonical Kotlin file class for JVM and Native platforms. https://github.com/pajato/KFile
👍 4
m
I think Native implementation can be adapted from scala-native: https://github.com/scala-native/scala-native/tree/master/javalib/src/main/scala/java/io
p
I will check it out. Thanks.
t
GPL :(
m
j
Why did you choose to make KFile an interface and not an “expected” class?
p
Mostly historic. I started off just to build a TextFile interface and that morphed into a KFile interface. Why do you ask? If I am missing something, and I easily could be, it would be good to know.
Actually a better answer is that I am partial to: a) interfaces and abstract classes over concrete classes, and b) factory methods over constructors.
r
Using interfaces in a library makes it easier for clients to mock the library out when they want to test their own logic in isolation.
d
Does kotlinx-io library not have a multiplatform file manipulation api?
I guess not
j
Thanks @pajatopmr! I just asked for curiosity, I’m still learning about Kotlin multiplatform and I feel a little lost in these cases to define something as “expect class” or interface. Thanks!
p
@thevery GPL was a mistake. I meant to use LGPL in case it matters. I will fix this on 0.0.2.
t
Of course it is your choice, but lgpl limits usage, too. Why not APL as most other libs and kotlin itself?