Skip to content

Commit

Permalink
Workaround a bug with SDL_GetPrefPath in Emscripten build
Browse files Browse the repository at this point in the history
Entirely 2014 me's fault.
  • Loading branch information
Daft-Freak committed Feb 4, 2021
1 parent 576dab6 commit 234a0e2
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion 32blit-sdl/File.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,13 @@ bool remove_file(const std::string &path) {
static std::string save_path;

const char *get_save_path() {
#ifdef __EMSCRIPTEN__
// The Emscripten backend's GetPrefPath is a little broken (doesn't create the dirs correctly)
// Work around it until the fix gets released
mkdir("/libsdl", 0700);
mkdir((std::string("/libsdl/") + metadata_author).c_str(), 0700);
#endif

auto tmp = SDL_GetPrefPath(metadata_author, metadata_title);
save_path = std::string(tmp);

Expand All @@ -198,4 +205,4 @@ const char *get_save_path() {

bool is_storage_available() {
return true;
}
}

0 comments on commit 234a0e2

Please sign in to comment.