Skip to content

Commit 9615b3d

Browse files
committed
fix: correctly implement the assets and root dir helper functions for emscripten
1 parent 3dfae40 commit 9615b3d

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/helper/graphic_utils.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ std::vector<std::string> utils::supported_features() {
3535
throw std::runtime_error{ "Failed in getting the Pref Path: " + std::string{ SDL_GetError() } };
3636
}
3737
return std::filesystem::path{ std::string{ pref_path } };
38+
#elif defined(__EMSCRIPTEN__)
39+
return std::filesystem::path{ "/" };
3840
#elif defined(__CONSOLE__)
3941
// this is in the sdcard of the switch / 3ds , since internal storage is read-only for applications!
4042
return std::filesystem::path{ "." };
@@ -64,7 +66,7 @@ std::vector<std::string> utils::supported_features() {
6466
#if defined(__SERENITY__)
6567

6668

67-
// this is a read write location in the serenityos case build, see https://docs.flatpak.org/en/latest/conventions.html
69+
// this is a read write location in the serenity-os case build, see https://docs.flatpak.org/en/latest/conventions.html
6870
const char* data_home = std::getenv("HOME");
6971
if (data_home == nullptr) {
7072
throw std::runtime_error{ "Failed to get flatpak data directory (XDG_DATA_HOME)" };
@@ -95,8 +97,11 @@ std::vector<std::string> utils::supported_features() {
9597
[[nodiscard]] std::filesystem::path utils::get_assets_folder() {
9698
#if defined(__ANDROID__)
9799
return std::filesystem::path{ "" };
100+
#elif defined(__EMSCRIPTEN__)
101+
// emscripten mounts a memfs in the / location, we package assest into this dir, see: https://emscripten.org/docs/porting/files/packaging_files.html#packaging-using-emcc
102+
return std::filesystem::path{ "/assets" };
98103
#elif defined(__CONSOLE__)
99-
// this is in the internal storage of the nintendo switch, it ios mounted by libnx (runtime switch support library) and filled at compile time with assets (its called ROMFS there)
104+
// this is in the internal storage of the nintendo switch, it is mounted by libnx (runtime switch support library) and filled at compile time with assets (its called ROMFS there)
100105
return std::filesystem::path{ "romfs:/assets" };
101106
#elif defined(BUILD_INSTALLER)
102107
// if you build in BUILD_INSTALLER mode, you have to assure that the data is there e.g. music + fonts!

0 commit comments

Comments
 (0)