diff options
Diffstat (limited to 'platform/ios/os_ios.mm')
-rw-r--r-- | platform/ios/os_ios.mm | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/platform/ios/os_ios.mm b/platform/ios/os_ios.mm index 160724618f..9a8cfc2593 100644 --- a/platform/ios/os_ios.mm +++ b/platform/ios/os_ios.mm @@ -90,7 +90,7 @@ OS_IOS *OS_IOS::get_singleton() { return (OS_IOS *)OS::get_singleton(); } -OS_IOS::OS_IOS(String p_data_dir, String p_cache_dir) { +OS_IOS::OS_IOS() { for (int i = 0; i < ios_init_callbacks_count; ++i) { ios_init_callbacks[i](); } @@ -101,11 +101,6 @@ OS_IOS::OS_IOS(String p_data_dir, String p_cache_dir) { main_loop = nullptr; - // can't call set_data_dir from here, since it requires DirAccess - // which is initialized in initialize_core - user_data_dir = p_data_dir; - cache_dir = p_cache_dir; - Vector<Logger *> loggers; loggers.push_back(memnew(SyslogLogger)); #ifdef DEBUG_ENABLED @@ -272,20 +267,25 @@ Error OS_IOS::shell_open(String p_uri) { } String OS_IOS::get_user_data_dir() const { - static bool user_data_dir_set = false; - if (user_data_dir_set) { - String old_dir = user_data_dir; - Ref<DirAccess> da = DirAccess::open(old_dir); - const_cast<OS_IOS *>(this)->user_data_dir = da->get_current_dir(); - user_data_dir_set = true; - - printf("setting data dir to %s from %s\n", user_data_dir.utf8().get_data(), old_dir.utf8().get_data()); + static String ret; + if (ret.is_empty()) { + NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); + if (paths && [paths count] >= 1) { + ret.parse_utf8([[paths firstObject] UTF8String]); + } } - return user_data_dir; + return ret; } String OS_IOS::get_cache_path() const { - return cache_dir; + static String ret; + if (ret.is_empty()) { + NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES); + if (paths && [paths count] >= 1) { + ret.parse_utf8([[paths firstObject] UTF8String]); + } + } + return ret; } String OS_IOS::get_locale() const { |