The following sections provide a brief overview of the Emscripten file system environment and architecture. In addition to discussing support for standard C/C++ synchronous file APIs, it briefly discusses the File System API and Emscripten’s Emscripten Asynchronous File System API.
Emscripten provides a virtual file system that simulates the local file system, so that native code using synchronous file APIs can be compiled and run with little or no change.
Packaging Files explains how you can use emcc to specify which files you need to include in the file system. For many developers, that may be all you need to do.
The main elements of the Emscripten File System architecture are shown below. Most native code will call the synchronous file APIs in libc and libcxx. These in turn call the underlying File System API, which by default uses the MEMFS virtual file system.
MEMFS is mounted at
If you need to fetch other files from the network to the file system then use
emscripten_wget() and the other methods in the Emscripten Asynchronous File System API. These methods are asynchronous and the application must wait until the registered callback completes before trying to read them.