| |
| |
| |
| |
| |
| |
|
|
| #include <assert.h> |
| #include <stdio.h> |
| #include <emscripten.h> |
|
|
| int main() { |
| EM_ASM( |
| var ex; |
| var contents; |
|
|
| |
| FS.writeFile('/safe.txt', 'abc'); |
|
|
| |
| FS.mkdir('/working'); |
| FS.mount(MEMFS, {}, '/working'); |
| FS.writeFile('/working/waka.txt', 'az'); |
|
|
| |
| contents = FS.readFile('/working/waka.txt', { encoding: 'utf8' }); |
| assert(contents === 'az'); |
|
|
| #if !defined(WASMFS) |
| |
| try { |
| FS.mount(MEMFS, {}, '/missing'); |
| } catch (e) { |
| ex = e; |
| } |
| assert(ex.name === 'ErrnoError' && ex.errno === 44); |
| ex = null; |
| #endif |
|
|
| #if WASMFS |
| |
| try { |
| FS.mkdir("/test"); |
| FS.writeFile("/test/hi.txt", "abc"); |
| FS.mount(MEMFS, {}, '/test'); |
| } catch (e) { |
| ex = e; |
| } |
| assert(ex.name === 'ErrnoError' && ex.errno === 55); |
| ex = null; |
| #endif |
|
|
| |
| try { |
| FS.mount(MEMFS, {}, '/working'); |
| } catch (e) { |
| ex = e; |
| } |
| #if WASMFS |
| |
| assert(ex.name === 'ErrnoError' && ex.errno === 55); |
| #else |
| assert(ex.name === 'ErrnoError' && ex.errno === 10); |
| #endif |
| ex = null; |
|
|
| |
| FS.mkdir('/working/unmountable'); |
| try { |
| FS.unmount('/working/unmountable'); |
| } catch (e) { |
| ex = e; |
| } |
| assert(ex.name === 'ErrnoError' && ex.errno === 28); |
| ex = null; |
|
|
| |
| FS.unmount('/working'); |
|
|
| |
| try { |
| FS.unmount('/working'); |
| } catch (e) { |
| ex = e; |
| } |
| #if WASMFS |
| |
| assert(ex.name === 'ErrnoError' && ex.errno === 44); |
| #else |
| assert(ex.name === 'ErrnoError' && ex.errno === 28); |
| #endif |
| ex = null; |
|
|
| |
| FS.mount(MEMFS, {}, '/working'); |
| FS.unmount('/working'); |
|
|
| ex = null; |
| |
| try { |
| FS.readFile('/working/waka.txt', { encoding: 'utf8' }); |
| } catch (e) { |
| ex = e; |
| } |
| #if !defined(WASMFS) |
| |
| assert(ex.name === 'ErrnoError' && ex.errno === 44); |
| #else |
| assert(ex); |
| #endif |
| ex = null; |
|
|
| |
| contents = FS.readFile('/safe.txt', { encoding: 'utf8' }); |
| assert(contents === 'abc'); |
|
|
| #if WASMFS |
| |
| FS.mount(JSFILEFS, {}, "/jsfile"); |
| FS.writeFile("/jsfile/jsfile.txt", "a=1"); |
| assert(FS.readFile("/jsfile/jsfile.txt", { encoding: 'utf8' }) === 'a=1'); |
| FS.unmount("/jsfile"); |
|
|
| |
| FS.mount(ICASEFS, { backend: MEMFS }, "/icase"); |
| FS.writeFile("/icase/IGNORE.txt", "a=1"); |
| assert(FS.readFile("/icase/Ignore.txt", { encoding: 'utf8' }) === 'a=1'); |
| assert(FS.readFile("/icase/ignore.TXT", { encoding: 'utf8' }) === 'a=1'); |
| FS.unmount("/icase"); |
| #endif |
| ); |
|
|
| puts("success"); |
|
|
| return 0; |
| } |
|
|