diff --git a/apple/iOS/menu.m b/apple/iOS/menu.m index 2ab4ecac79..081020bd5d 100644 --- a/apple/iOS/menu.m +++ b/apple/iOS/menu.m @@ -899,6 +899,32 @@ static void RunActionSheet(const char* title, const struct string_list* items, U [self.navigationController pushViewController:[[RACoreSettingsMenu alloc] initWithCore:core] animated:YES]; } +static bool copy_config(const char *src_path, const char *dst_path) +{ + char ch; + FILE *dst; + FILE *src = fopen(src_path, "r"); + + if (!src) + return false; + + dst = fopen(dst_path, "w"); + + if (!dst) + { + fclose(src); + return false; + } + + while((ch = fgetc(src)) != EOF) + fputc(ch, dst); + + fclose(src); + fclose(dst); + + return true; +} + - (void)createNewConfig { RAFrontendSettingsMenu* __weak weakSelf = self; @@ -909,9 +935,14 @@ static void RunActionSheet(const char* title, const struct string_list* items, U { char path[PATH_MAX]; core_info_get_custom_config(core.UTF8String, path, sizeof(path)); - - if (![[NSFileManager defaultManager] copyItemAtPath:BOXSTRING(g_defaults.config_path) toPath:BOXSTRING(path) error:nil]) - RARCH_WARN("Could not create custom config at %s", path); + + if (g_defaults.config_path[0] != '\0' && path[0] != '\0') + { + if (!copy_config(g_defaults.config_path, path)) + { + RARCH_WARN("Could not create custom config at %s.", path); + } + } } [weakSelf.navigationController popViewControllerAnimated:YES]; diff --git a/apple/iOS/platform.h b/apple/iOS/platform.h index 1a5d7b02f1..01d88e2654 100644 --- a/apple/iOS/platform.h +++ b/apple/iOS/platform.h @@ -48,7 +48,6 @@ const void* apple_get_frontend_settings(void); @property (nonatomic) NSString* configDirectory; // e.g. /var/mobile/Documents/.RetroArch -@property (nonatomic) NSString* globalConfigFile; // e.g. /var/mobile/Documents/.RetroArch/retroarch.cfg @property (nonatomic) NSString* coreDirectory; // e.g. /Applications/RetroArch.app/modules @property (nonatomic) NSString* documentsDirectory; // e.g. /var/mobile/Documents diff --git a/apple/iOS/platform.m b/apple/iOS/platform.m index 713f38992c..78ffefc43b 100644 --- a/apple/iOS/platform.m +++ b/apple/iOS/platform.m @@ -201,7 +201,7 @@ static void handle_touch_event(NSArray* touches) self.systemDirectory = [self.documentsDirectory stringByAppendingPathComponent:@".RetroArch"]; self.configDirectory = self.systemDirectory; - self.globalConfigFile = [NSString stringWithFormat:@"%@/retroarch.cfg", self.configDirectory]; + snprintf(g_defaults.config_path, sizeof(g_defaults.config_path), "%s/retroarch.cfg", self.configDirectory.UTF8String); self.coreDirectory = [NSBundle.mainBundle.bundlePath stringByAppendingPathComponent:@"modules"]; path = (const char*)self.documentsDirectory.UTF8String;