From 0c066ad10f53a71f864035e5be9720857fdbd4ac Mon Sep 17 00:00:00 2001 From: Jeremy Rose Date: Fri, 5 Jan 2024 19:54:14 -0800 Subject: [PATCH] put filesystem.cpp changes behind #define --- src/filesystem.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/filesystem.cpp b/src/filesystem.cpp index 873ceecd958c3..f0a5a8b406e36 100644 --- a/src/filesystem.cpp +++ b/src/filesystem.cpp @@ -19,8 +19,19 @@ # include "platform_win.h" #endif +#if defined(EMSCRIPTEN) #include +void setFsNeedsSync() +{ + EM_ASM(window.idb_needs_sync = true;); +} +#else +void setFsNeedsSync() +{ +} +#endif + bool assure_dir_exist( const std::string &path ) { return assure_dir_exist( fs::u8path( path ) ); @@ -33,7 +44,7 @@ bool assure_dir_exist( const cata_path &path ) bool assure_dir_exist( const fs::path &path ) { - EM_ASM(window.idb_needs_sync = true;); + setFsNeedsSync(); std::error_code ec; bool exists{false}; bool created{false}; @@ -104,7 +115,7 @@ bool remove_file( const std::string &path ) bool remove_file( const fs::path &path ) { - EM_ASM(window.idb_needs_sync = true;); + setFsNeedsSync(); std::error_code ec; return fs::remove( path, ec ); } @@ -116,7 +127,7 @@ bool rename_file( const std::string &old_path, const std::string &new_path ) bool rename_file( const fs::path &old_path, const fs::path &new_path ) { - EM_ASM(window.idb_needs_sync = true;); + setFsNeedsSync(); std::error_code ec; fs::rename( old_path, new_path, ec ); return !ec; @@ -140,7 +151,7 @@ bool remove_directory( const std::string &path ) bool remove_directory( const fs::path &path ) { std::error_code ec; - EM_ASM(window.idb_needs_sync = true;); + setFsNeedsSync(); return fs::remove( path, ec ); }