aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Bishop <mbtyke@gmail.com>2013-09-23 19:22:37 -0400
committerJukka Jylänki <jujjyl@gmail.com>2014-04-29 14:57:45 +0300
commitd341059aaef966f3d9a34519802f451347f679eb (patch)
treeb1a2fa077b8cc72b86e7de34a3d69a8cdcaca38e /src
parenta7dfddc6abee48cc9484fe8f08f45d053f08dae2 (diff)
Added FileSystem tracking Support.
Diffstat (limited to 'src')
-rw-r--r--src/library_fs.js25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/library_fs.js b/src/library_fs.js
index d53210f9..e7e194cf 100644
--- a/src/library_fs.js
+++ b/src/library_fs.js
@@ -26,7 +26,13 @@ mergeInto(LibraryManager.library, {
// This is set to false when the runtime is initialized, allowing you
// to modify the filesystem freely before run() is called.
ignorePermissions: true,
-
+ trackingDelegate: {},
+ tracking: {
+ openFlags: {
+ READ: 1 << 0,
+ WRITE: 1 << 1
+ }
+ },
ErrnoError: null, // set during init
genericErrors: {},
@@ -725,6 +731,12 @@ mergeInto(LibraryManager.library, {
// changed its name)
FS.hashAddNode(old_node);
}
+ if (FS.trackingDelegate) {
+ if (FS.trackingDelegate['didDeleteFile'])
+ FS.trackingDelegate['didDeleteFile'](old_path);
+ if (FS.trackingDelegate['didOpenFile'])
+ FS.trackingDelegate['didOpenFile'](new_path, FS.tracking.openFlags.WRITE);
+ }
},
rmdir: function(path) {
var lookup = FS.lookupPath(path, { parent: true });
@@ -771,6 +783,9 @@ mergeInto(LibraryManager.library, {
}
parent.node_ops.unlink(parent, name);
FS.destroyNode(node);
+ if (FS.trackingDelegate && FS.trackingDelegate['didDeleteFile']) {
+ FS.trackingDelegate['didDeleteFile'](path);
+ }
},
readlink: function(path) {
var lookup = FS.lookupPath(path);
@@ -965,6 +980,14 @@ mergeInto(LibraryManager.library, {
Module['printErr']('read file: ' + path);
}
}
+ if (FS.trackingDelegate && FS.trackingDelegate['didOpenFile']) {
+ var trackingFlags = 0;
+ if (!(flags & {{{ cDefine('O_WRONLY')}}}))
+ trackingFlags != FS.tracking.openFlags.READ;
+ if (!(flags & {{{ cDefine('O_RDONLY')}}}))
+ trackingFlags != FS.tracking.openFlags.WRITE;
+ FS.trackingDelegate['didOpenFile'](path, trackingFlags);
+ }
return stream;
},
close: function(stream) {