summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
Diffstat (limited to 'platform')
-rw-r--r--platform/ios/app_delegate.mm9
-rw-r--r--platform/ios/godot_ios.mm8
-rw-r--r--platform/ios/os_ios.h5
-rw-r--r--platform/ios/os_ios.mm32
4 files changed, 21 insertions, 33 deletions
diff --git a/platform/ios/app_delegate.mm b/platform/ios/app_delegate.mm
index fb183d52d4..3ebd530585 100644
--- a/platform/ios/app_delegate.mm
+++ b/platform/ios/app_delegate.mm
@@ -45,7 +45,7 @@
extern int gargc;
extern char **gargv;
-extern int ios_main(int, char **, String, String);
+extern int ios_main(int, char **);
extern void ios_finish();
@implementation AppDelegate
@@ -66,12 +66,7 @@ static ViewController *mainViewController = nil;
// Create a full-screen window
self.window = [[UIWindow alloc] initWithFrame:windowBounds];
- NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
- NSString *documentsDirectory = [paths objectAtIndex:0];
- paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
- NSString *cacheDirectory = [paths objectAtIndex:0];
-
- int err = ios_main(gargc, gargv, String::utf8([documentsDirectory UTF8String]), String::utf8([cacheDirectory UTF8String]));
+ int err = ios_main(gargc, gargv);
if (err != 0) {
// bail, things did not go very well for us, should probably output a message on screen with our error code...
diff --git a/platform/ios/godot_ios.mm b/platform/ios/godot_ios.mm
index 5f3e786b8a..abe7c59ce2 100644
--- a/platform/ios/godot_ios.mm
+++ b/platform/ios/godot_ios.mm
@@ -38,10 +38,6 @@
static OS_IOS *os = nullptr;
-int add_path(int, char **);
-int add_cmdline(int, char **);
-int ios_main(int, char **, String);
-
int add_path(int p_argc, char **p_args) {
NSString *str = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"godot_path"];
if (!str) {
@@ -74,7 +70,7 @@ int add_cmdline(int p_argc, char **p_args) {
return p_argc;
}
-int ios_main(int argc, char **argv, String data_dir, String cache_dir) {
+int ios_main(int argc, char **argv) {
size_t len = strlen(argv[0]);
while (len--) {
@@ -95,7 +91,7 @@ int ios_main(int argc, char **argv, String data_dir, String cache_dir) {
char cwd[512];
getcwd(cwd, sizeof(cwd));
printf("cwd %s\n", cwd);
- os = new OS_IOS(data_dir, cache_dir);
+ os = new OS_IOS();
// We must override main when testing is enabled
TEST_MAIN_OVERRIDE
diff --git a/platform/ios/os_ios.h b/platform/ios/os_ios.h
index 0c23b216c5..3560de7486 100644
--- a/platform/ios/os_ios.h
+++ b/platform/ios/os_ios.h
@@ -71,9 +71,6 @@ private:
virtual void finalize() override;
- String user_data_dir;
- String cache_dir;
-
bool is_focused = false;
void deinitialize_modules();
@@ -81,7 +78,7 @@ private:
public:
static OS_IOS *get_singleton();
- OS_IOS(String p_data_dir, String p_cache_dir);
+ OS_IOS();
~OS_IOS();
void initialize_modules();
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 {