I'm currently working on a file parsing library in C with emscripten compile support. It takes a file path from the user where it reads the binary file and parses it.
I understand that emscripten doesn't support direct loading of files, but instead uses a virtual filesystem. Is there any way to load the file at the given path into the virtual filesystem so that the emscripten compiled C lib can read it? I'm looking for solutions for both NodeJS and in the browser.
Emscripten, as of today (June 2016), supports a filesystem called NODEFS
which provides access to the local file-system when running on nodejs
.
You need to manually mount the NODEFS
filesystem into the root filesystem. For example:
EM_ASM(
FS.mkdir('/working');
FS.mount(NODEFS, { root: '.' }, '/working');
);
You can then access ./abc
from the local filesystem via the virtual path /working/abc
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With