I'm using empscripten with nodejs.

Questions:

1. What's the best way to access require('fs') in js library code?
2. Is there something like EM_ASM() which can return a value?
3. Is there a better way to do what I'm trying to do (see code below).

Here is the js library code I want to use:

mergeInto(LibraryManager.library, {
  readch: function() {
            var fs = Module.fs;
            var buf = Buffer(10);
            var fd = fs.openSync('/dev/stdin', 'rs')
            var nread = fs.readSync(fd, buf, 0, 1, null);
            if (nread > 0) {
              return buf[0];
            } else {
              return 0;
            }
          }
  }
)

Note that it accesses Module.fs which is not normally defined. To get it to 
work I hack the a.out.js file to include the assignment around line 52:

Module['fs'] = nodeFS;

Thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to