Hi everyone. help me pls. How can I get resources ...
# kotlin-native
z
Hi everyone. help me pls. How can I get resources in kotlin-native? I cannot use this example:
Copy code
UtilsTests::class..getResource("/source.pst")
How can I get classpath?
k
z
Thanks, but it is not that I want. I do not know syntax kotlin-native how I can access some files in resources
kotlin-native does not have classloader and I could not find something else
d
You have two options.
You can reference you resource files directly.
Or you can bundle the files into your output/binary/klib.
The latter is a bit tricky.
z
I cannot reference to file directly, because app runs on the different os. I need to find possibility relative reference to file.
a
For loading resources, you should use POSIX lib functions from
platform.posix.*
, with manual opening and reading files you need. I suppose, it also solves your problem with relative paths, it can be managed with standard glob syntax. If you got a case where the program has to bring some data with itself, you can try to use an
ImmutableBlob
class for this purpose (https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.native/-immutable-blob/index.html)
z
Thanks, I`ll try