diff --git a/source/code/os.cpp b/source/code/os.cpp index 4ab6759..9108ae9 100644 --- a/source/code/os.cpp +++ b/source/code/os.cpp @@ -36,14 +36,7 @@ https://blockattack.net #endif #include -#if defined(__EMSCRIPTEN__) -// Emscripten's getuid() stub reports root, which makes PlatformFolders look up -// a passwd entry that does not exist. The browser build uses a fixed path that -// only serves as the IDBFS mount point (see OsMountPersistentStorage). -static const char* const webSaveFolder = "/home/web_user/.local/share"; -#else static sago::PlatformFolders pf; -#endif static std::string overrideSavePath = ""; @@ -57,11 +50,7 @@ std::string getPathToSaveFiles() { if (overrideSavePath.length() > 0) { return overrideSavePath; } -#if defined(__EMSCRIPTEN__) - return std::string(webSaveFolder)+"/"+GAMENAME; -#else return pf.getSaveGamesFolder1()+"/"+GAMENAME; -#endif } std::string getPathToStateFiles() { diff --git a/source/misc/embedded_libs/PlatformFolders-4.2.0/sago/platform_folders.cpp b/source/misc/embedded_libs/PlatformFolders-4.2.0/sago/platform_folders.cpp index b1a0874..f94237d 100644 --- a/source/misc/embedded_libs/PlatformFolders-4.2.0/sago/platform_folders.cpp +++ b/source/misc/embedded_libs/PlatformFolders-4.2.0/sago/platform_folders.cpp @@ -52,6 +52,15 @@ static std::string getHome() { res = homeEnv; return res; } +#if defined(__EMSCRIPTEN__) + if ( homeEnv) { + //With Emscripten we always acknowledge home + res = homeEnv; + return res; + } + res = "/home/web_user"; + return res; //Always use a fixed folder for Emscripten +#endif struct passwd* pw = nullptr; struct passwd pwd; long bufsize = sysconf(_SC_GETPW_R_SIZE_MAX);