From 093c463ebf3da960b12274b7f7fe9a5ddafac0bb Mon Sep 17 00:00:00 2001 From: Fabio Alessandrelli Date: Wed, 1 Jul 2020 15:40:30 +0200 Subject: [PATCH] [HTML5] Early FS initialization. So that "/userfs" is created and mounted before `setup`. --- platform/javascript/javascript_main.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/platform/javascript/javascript_main.cpp b/platform/javascript/javascript_main.cpp index bb889fcf7c0..052ed24279b 100644 --- a/platform/javascript/javascript_main.cpp +++ b/platform/javascript/javascript_main.cpp @@ -120,9 +120,12 @@ extern "C" EMSCRIPTEN_KEEPALIVE void main_after_fs_sync(char *p_idbfs_err) { } int main(int argc, char *argv[]) { - + // Create and mount userfs immediately. + EM_ASM({ + FS.mkdir('/userfs'); + FS.mount(IDBFS, {}, '/userfs'); + }); os = new OS_JavaScript(argc, argv); - // TODO: Check error return value. Main::setup(argv[0], argc - 1, &argv[1], false); emscripten_set_main_loop(main_loop_callback, -1, false); emscripten_pause_main_loop(); // Will need to wait for FS sync. @@ -131,8 +134,6 @@ int main(int argc, char *argv[]) { // run the 'main_after_fs_sync' function. /* clang-format off */ EM_ASM({ - FS.mkdir('/userfs'); - FS.mount(IDBFS, {}, '/userfs'); FS.syncfs(true, function(err) { requestAnimationFrame(function() { ccall('main_after_fs_sync', null, ['string'], [err ? err.message : ""]);