+
+
+// ============================================================================
+// Emscripten functions
+// ============================================================================
+
+void InitEmscriptenFilesystem(void)
+{
+#if defined(PLATFORM_EMSCRIPTEN)
+ EM_ASM
+ (
+ Module.sync_done = 0;
+
+ FS.mkdir('/persistent'); // create persistent data directory
+ FS.mount(IDBFS, {}, '/persistent'); // mount with IDBFS filesystem type
+ FS.syncfs(true, function(err) // sync persistent data into memory
+ {
+ assert(!err);
+ Module.sync_done = 1;
+ });
+ );
+
+ // wait for persistent data to be synchronized to memory
+ while (emscripten_run_script_int("Module.sync_done") == 0)
+ Delay(20);
+#endif
+}
+
+void SyncEmscriptenFilesystem(void)
+{
+#if defined(PLATFORM_EMSCRIPTEN)
+ EM_ASM
+ (
+ FS.syncfs(function(err)
+ {
+ assert(!err);
+ });
+ );
+#endif
+}