// Copyright 2017 The Emscripten Authors. All rights reserved.1// Emscripten is available under two separate licenses, the MIT license and the2// University of Illinois/NCSA Open Source License. Both these licenses can be3// found in the LICENSE file.45#include <emscripten.h>6#include <stdio.h>78int main() {9#ifdef USE_FILES10if (fopen("nonexistend", "r")) {11puts("that was bad");12return 1;13}14#endif15#ifdef DIRECT16EM_ASM({17FS.createDataFile("/", "file.txt", [1, 2, 3]);18});19#else20EM_ASM({21Module["FS_createDataFile"]("/", "file.txt", [1, 2, 3]);22});23#endif24EM_ASM({25// use eval, so that the compiler can't see FS usage statically26eval('out("Data: " + JSON.stringify(Array.from(MEMFS.getFileDataAsTypedArray(FS.root.contents["file.txt"]))))');27});28}29303132