diff options
author | max99x <max99x@gmail.com> | 2011-07-22 21:36:14 +0300 |
---|---|---|
committer | max99x <max99x@gmail.com> | 2011-07-22 23:31:57 +0300 |
commit | 5f9646ca267736036e87afc965e665539eed3578 (patch) | |
tree | 29f7928e8e37fc7a968434b8fad87d25ce2b5e8f /tests/filesystem/src.js | |
parent | 4f25c5b69954137557da89973f10d121cdb4a980 (diff) |
Added FS.analyzePath() which will simplify some library functions.
Diffstat (limited to 'tests/filesystem/src.js')
-rw-r--r-- | tests/filesystem/src.js | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/filesystem/src.js b/tests/filesystem/src.js new file mode 100644 index 00000000..5fdef564 --- /dev/null +++ b/tests/filesystem/src.js @@ -0,0 +1,46 @@ +FS.createFolder('/', 'forbidden', false, false); +FS.createFolder('/forbidden', 'test', true, true); +FS.createPath('/', 'abc/123', true, true); +FS.createPath('/', 'abc/456', true, true); +FS.createPath('/', 'def/789', true, true); +FS.createDevice('/abc', 'deviceA', function() {}, function() {}); +FS.createDevice('/def', 'deviceB', function() {}, function() {}); +FS.createLink('/abc', 'localLink', '123', true, true); +FS.createLink('/abc', 'rootLink', '/', true, true); +FS.createLink('/abc', 'relativeLink', '../def', true, true); + +function explore(path) { + print(path); + var ret = FS.analyzePath(path); + print(' isRoot: ' + ret.isRoot); + print(' exists: ' + ret.exists); + print(' error: ' + ret.error); + print(' path: ' + ret.path); + print(' name: ' + ret.name); + print(' object.contents: ' + (ret.object && JSON.stringify(Object.keys(ret.object.contents || {})))); + print(' parentExists: ' + ret.parentExists); + print(' parentPath: ' + ret.parentPath); + print(' parentObject.contents: ' + (ret.parentObject && JSON.stringify(Object.keys(ret.parentObject.contents)))); + print(''); +} + +FS.currentPath = '/abc'; +explore(''); +explore('/'); +explore('.'); +explore('..'); +explore('../..'); +explore('/abc'); +explore('/abc/123'); +explore('/abc/noexist'); +explore('/abc/deviceA'); +explore('/abc/localLink'); +explore('/abc/rootLink'); +explore('/abc/relativeLink'); +explore('/abc/relativeLink/deviceB'); +explore('/abc/rootLink/noexist'); +explore('/abc/rootLink/abc/noexist'); +explore('/forbidden'); +explore('/forbidden/test'); +explore('/forbidden/noexist'); +explore('/noexist1/noexist2'); |