Dealing with Files ================== Emscripten provides several options for supporting programs that need to handle file-based input and output. Part of the boilerplate wrapped around output programs is support for a basic virtualized file system and implementations of the C standard library functions for doing IO. Basic File Support ------------------ If a program only needs to read from pre-existing data files, they can be compiled directly in to the output JavaScript. To do so, use the ``--preload-file`` flag to ``emcc``, passing a file or directory as an argument. The file(s) will then be accessible by name from ``fopen`` and other function calls from within the program. File System API --------------- For more advanced file system support, Emscripten provides a JavaScript-based file system API that allows for the dynamic creation and deletion of files, directories and symlinks. The official documentation at https://github.com/kripken/emscripten/wiki/Filesystem-Guide provides a good overview. Creating Files and Directories ______________________________ Interacting with Emscripten's file system is fairly straightforward from within a HTML page containing the generated Javascript. To add a file to the file system, place the following Javascript within ``