kripken/emscripten — pull request #1601 by inolen (2013-09-07 07:14:52+00:00)
Title: NODEFS and IDBFS support

With this, this marks the end of the fs / socket improvements I wanted to make originally. I'm rushing pulling this a bit as I'm running out of free time for this project. o1 and other tests have been ran.

NODEFS is somewhat straight forward - the node and stream operations it implements for the most part just call into an equivalent node fs API call.

IDBFS is somewhat unique and I _think_ a decent idea. The idea is that it actually just completely re-uses MEMFS (look at IDBFS::mount). However, I've now added a new async `FS::syncfs` call that will call into the filesystem object's syncfs function, which IDBFS implements. `FS::syncfs` isn't meant to be used by any libc calls, but it provides a way for modules to preload / sync the filesystem asynchronously in the JS layer. For example, quakejs has it's own internal filesystem startup / shutdown functions that look like this:

Sys_FS_Startup: function (callback) {
FS.mkdir('/baseq3');
FS.mount(IDBFS, {}, '/baseq3');

FS.syncfs(true, function (err) {
if (err) throw err;
// handle callback
});
},
Sys_FS_Shutdown: function (callback) {
FS.syncfs(function (err) {
// handle callback
});
},

With this, any file / directory saved to IDBFS will be sync'd with the underlying IndexedDB.

In addition, there were a few minor fixes made in the first commit to the FS layer, and the unistd_* tests were updated to test against NODEFS.

Next up, documentation.