aboutsummaryrefslogtreecommitdiff
path: root/tests/filesystem/src.js
blob: 801b45d6d44b2a1032149ba1d8766232f902ecc9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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) {
  Module.print(path);
  var ret = FS.analyzePath(path);
  Module.print('  isRoot: ' + ret.isRoot);
  Module.print('  exists: ' + ret.exists);
  Module.print('  error: ' + ret.error);
  Module.print('  path: ' + ret.path);
  Module.print('  name: ' + ret.name);
  Module.print('  object.contents: ' + (ret.object && JSON.stringify(Object.keys(ret.object.contents || {}))));
  Module.print('  parentExists: ' + ret.parentExists);
  Module.print('  parentPath: ' + ret.parentPath);
  Module.print('  parentObject.contents: ' + (ret.parentObject && JSON.stringify(Object.keys(ret.parentObject.contents))));
  Module.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');