From 912453df4c00e312f03c571ef988bd5bdb626a70 Mon Sep 17 00:00:00 2001 From: Victor Sergienko Date: Tue, 9 May 2017 22:50:31 -0700 Subject: [PATCH] iOS document directories. Might use these on other platforms as well. --- src/filesystem.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/filesystem.cpp b/src/filesystem.cpp index 172c8dda06e3..757fca5a658a 100644 --- a/src/filesystem.cpp +++ b/src/filesystem.cpp @@ -52,6 +52,15 @@ #include #include +// Copied from boost::predef, as it's there only since 1.55. +#if defined(__APPLE__) && defined(__MACH__) && defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) + +#define WESNOTH_BOOST_OS_IOS (__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__*1000) +#include + +#endif + + static lg::log_domain log_filesystem("filesystem"); #define DBG_FS LOG_STREAM(debug, log_filesystem) #define LOG_FS LOG_STREAM(info, log_filesystem) @@ -617,6 +626,14 @@ void set_user_data_dir(std::string newprefdir) std::string backupprefdir = ".wesnoth" + get_version_path_suffix(); +#ifdef WESNOTH_BOOST_OS_IOS + char *sdl_pref_path = SDL_GetPrefPath("wesnoth.org", "iWesnoth"); + if(sdl_pref_path) { + backupprefdir = std::string(sdl_pref_path) + backupprefdir; + SDL_free(sdl_pref_path); + } +#endif + #ifdef _X11 const char* home_str = getenv("HOME");