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.
If you want compile this file directly into library you can use --preload-file or --embed-file option. Like this:
emcc main.cpp -o main.html --preload-file /tmp/my@/home/caiiiycuk/test.file
After that in C you can open this file normally:
fopen("/home/caiiiycuk/test.file", "rb")
Or you can use emscripten javascript fs-api, for example with ajax:
$.ajax({
url: "/dataurl",
type: 'GET',
beforeSend: function (xhr) {
xhr.overrideMimeType("text/plain; charset=x-user-defined");
},
success: function( data ) {
Module['FS_createDataFile']("/tmp", "test.file", data, true, true);
}
});
After that you can open this file from C. Also it is not best way to pass data into C code, you can pass data directly in memory, read about this.