diff options
author | Alon Zakai <alonzakai@gmail.com> | 2011-08-07 21:35:17 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2011-08-07 21:35:17 -0700 |
commit | 7172aacb563367fae198c25743827ef1195083aa (patch) | |
tree | 6681cb0ce8a247e79f7f5fbe4c2b252f3248187a /src | |
parent | 19d18fbffd8f79bbe7cece5806903b2a6c1561e9 (diff) |
filesystem workaround for closure compiler, +closure compiler test
Diffstat (limited to 'src')
-rw-r--r-- | src/library.js | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/src/library.js b/src/library.js index 4d7e95b3..e2d75f84 100644 --- a/src/library.js +++ b/src/library.js @@ -25,16 +25,6 @@ LibraryManager.library = { $FS__deps: ['$ERRNO_CODES', '__setErrNo', 'stdin', 'stdout', 'stderr'], $FS__postset: 'FS.init();', $FS: { - // The main file system tree. All the contents are inside this. - root: { - read: true, - write: false, - isFolder: true, - isDevice: false, - timestamp: Date.now(), - inodeNumber: 1, - contents: {} - }, // The path to the current folder. currentPath: '/', // The inode to assign to the next created object. @@ -145,6 +135,7 @@ LibraryManager.library = { // set to true and the object is a symbolic link, it will be returned as is // instead of being resolved. Links embedded in the path as still resolved. findObject: function(path, dontResolveLastLink) { + FS.ensureRoot(); var ret = FS.analyzePath(path, dontResolveLastLink); if (ret.exists) { return ret.object; @@ -286,12 +277,27 @@ LibraryManager.library = { if (!success) ___setErrNo(ERRNO_CODES.EIO); return success; }, + ensureRoot: function() { + if (FS.root) return; + // The main file system tree. All the contents are inside this. + FS.root = { + read: true, + write: false, + isFolder: true, + isDevice: false, + timestamp: Date.now(), + inodeNumber: 1, + contents: {} + }; + }, // Initializes the filesystems with stdin/stdout/stderr devices, given // optional handlers. init: function(input, output, error) { // Make sure we initialize only once. if (FS.init.initialized) return; - else FS.init.initialized = true; + FS.init.initialized = true; + + FS.ensureRoot(); // Default handlers. if (!input) input = function() { |