Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
emscripten-core
GitHub Repository: emscripten-core/emscripten
Path: blob/main/test/core/FS_exports.cpp
4150 views
1
// Copyright 2017 The Emscripten Authors. All rights reserved.
2
// Emscripten is available under two separate licenses, the MIT license and the
3
// University of Illinois/NCSA Open Source License. Both these licenses can be
4
// found in the LICENSE file.
5
6
#include <emscripten.h>
7
#include <stdio.h>
8
9
int main() {
10
#ifdef USE_FILES
11
if (fopen("nonexistend", "r")) {
12
puts("that was bad");
13
return 1;
14
}
15
#endif
16
#ifdef DIRECT
17
EM_ASM({
18
FS.createDataFile("/", "file.txt", [1, 2, 3]);
19
});
20
#else
21
EM_ASM({
22
Module["FS_createDataFile"]("/", "file.txt", [1, 2, 3]);
23
});
24
#endif
25
EM_ASM({
26
// use eval, so that the compiler can't see FS usage statically
27
eval('out("Data: " + JSON.stringify(Array.from(MEMFS.getFileDataAsTypedArray(FS.root.contents["file.txt"]))))');
28
});
29
}
30
31
32