https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
a

atsushieno

08/28/2021, 9:59 AM
How can my app code access to the files added as
src/commonMain/resources
from native executable built as
binaries.executable()
?
👀 2
b

Big Chungus

08/28/2021, 10:01 AM
I'd assume in the same way you'd access embedded resources in c (is that even possible?)
a

atsushieno

08/28/2021, 10:03 AM
Do you mean, using C fucntions like
fopen()
? But I don't see my resources under
build/bin
etc. Is it bundled in
.kexe
?
b

Big Chungus

08/28/2021, 10:06 AM
No, fopen is for normal files only. I was wondering if c has some sort of flows for accessing embedded files. Something like jvm's loadResourceFromClasspath()
a

atsushieno

08/28/2021, 10:06 AM
Yeah that would resolve the problem, if exists.
b

Big Chungus

08/28/2021, 10:07 AM
Not c though, since googling for c always gives results for c#...
a

atsushieno

08/28/2021, 10:08 AM
lol
and I need cross-platform solution, not just Windows...
e

ephemient

08/28/2021, 10:14 AM
no, there's nothing like this for cross-platform C
😥 1
b

Big Chungus

08/28/2021, 10:16 AM
Then you could just copy processedResources into the binary directory and open them up via fopen
Essentially distributing them alongside your binary. Not ideal, but gets the job done.
e

ephemient

08/28/2021, 10:17 AM
the trick I've used is equivalent to https://csl.name/post/embedding-binary-data/
the codegen approach is doable without platform specifics but can cause the compiler to blow up with large artifacts
a

atsushieno

08/28/2021, 11:11 AM
Well, yeah I don't think I'm going to hack kotlinc or klib to embed resources into .kexe. Copying resources to each build output directory would suffice. That seems an overlooked task at kotlin gradle plugin though.
b

Big Chungus

08/28/2021, 11:12 AM
Indeed. It's still fairly recently that they've fixed it for js. Might be worth raising an issue or a PR for native too.
a

atsushieno

08/28/2021, 11:13 AM
yup, am looking at youtrack now. Thanks folks.
o

oianmol

09/13/2022, 5:10 AM
Any progress here ? 🤔
a

atsushieno

09/13/2022, 5:30 AM
You should ask JetBrains devs via youtrack, maybe not those who submitted the issues?