From: Holger Schemel Date: Sat, 9 Apr 2022 10:09:07 +0000 (+0200) Subject: added definition for persistent directory name for Emscripten platform X-Git-Tag: 4.3.2.0~28 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=a534d294e41a0bc2c5e77e7b12786f8d0a9b5ae1;p=rocksndiamonds.git added definition for persistent directory name for Emscripten platform --- diff --git a/src/libgame/setup.c b/src/libgame/setup.c index b78d274e..60bb5685 100644 --- a/src/libgame/setup.c +++ b/src/libgame/setup.c @@ -1756,7 +1756,7 @@ char *getHomeDir(void) strcpy(dir, "."); } #elif defined(PLATFORM_EMSCRIPTEN) - dir = "/persistent"; + dir = PERSISTENT_DIRECTORY; #elif defined(PLATFORM_UNIX) if (dir == NULL) { diff --git a/src/libgame/system.c b/src/libgame/system.c index f9cc4fe8..196e15dc 100644 --- a/src/libgame/system.c +++ b/src/libgame/system.c @@ -1908,17 +1908,19 @@ void InitEmscriptenFilesystem(void) { #if defined(PLATFORM_EMSCRIPTEN) EM_ASM - ( + ({ + dir = UTF8ToString($0); + Module.sync_done = 0; - FS.mkdir('/persistent'); // create persistent data directory - FS.mount(IDBFS, {}, '/persistent'); // mount with IDBFS filesystem type + FS.mkdir(dir); // create persistent data directory + FS.mount(IDBFS, {}, dir); // mount with IDBFS filesystem type FS.syncfs(true, function(err) // sync persistent data into memory { assert(!err); Module.sync_done = 1; }); - ); + }, PERSISTENT_DIRECTORY); // wait for persistent data to be synchronized to memory while (emscripten_run_script_int("Module.sync_done") == 0) diff --git a/src/libgame/system.h b/src/libgame/system.h index aea0130a..97615e6d 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -662,6 +662,7 @@ #define CONF_DIRECTORY "conf" #define NETWORK_DIRECTORY "network" #define USERS_DIRECTORY "users" +#define PERSISTENT_DIRECTORY "/persistent" #define GFX_CLASSIC_SUBDIR "gfx_classic" #define SND_CLASSIC_SUBDIR "snd_classic"