How do I read a user-specified file in an emscripten compiled library?

前端 未结 4 920
北荒
北荒 2021-01-11 19:07

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.

4条回答
  •  滥情空心
    2021-01-11 19:59

    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.

提交回复
热议问题