If you want to compile this file directly in the library, you can use the --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 normally open this file:
fopen("/home/caiiiycuk/test.file", "rb")
Or you can use emscripten javascript fs-api , for example using 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 with C. Also not the best way to transfer data to C-code, you can transfer data directly to memory, read about it .
caiiiycuk
source share