From 3bee3cfeadcb57833a90c7789333750676f39e81 Mon Sep 17 00:00:00 2001 From: Robert Ou Date: Wed, 15 Nov 2017 03:14:14 -0800 Subject: Mount NODEFS if using emscripten and nodejs Mounts root directory on `/hostfs` and the current working directory on `/hostcwd` --- icebram/icebram.cc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'icebram') diff --git a/icebram/icebram.cc b/icebram/icebram.cc index 245a0ab..a796f92 100644 --- a/icebram/icebram.cc +++ b/icebram/icebram.cc @@ -28,6 +28,10 @@ #include #include +#ifdef __EMSCRIPTEN__ +#include +#endif + using std::map; using std::pair; using std::vector; @@ -109,6 +113,18 @@ void help(const char *cmd) int main(int argc, char **argv) { +#ifdef __EMSCRIPTEN__ + EM_ASM( + if (ENVIRONMENT_IS_NODE) + { + FS.mkdir('/hostcwd'); + FS.mount(NODEFS, { root: '.' }, '/hostcwd'); + FS.mkdir('/hostfs'); + FS.mount(NODEFS, { root: '/' }, '/hostfs'); + } + ); +#endif + bool verbose = false; bool generate = false; -- cgit v1.2.3