(Apple/iOS) Kill dependency on ObjC copyItemAtPath
This commit is contained in:
parent
3242cc998a
commit
92e67a4382
|
@ -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];
|
[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
|
- (void)createNewConfig
|
||||||
{
|
{
|
||||||
RAFrontendSettingsMenu* __weak weakSelf = self;
|
RAFrontendSettingsMenu* __weak weakSelf = self;
|
||||||
|
@ -910,8 +936,13 @@ static void RunActionSheet(const char* title, const struct string_list* items, U
|
||||||
char path[PATH_MAX];
|
char path[PATH_MAX];
|
||||||
core_info_get_custom_config(core.UTF8String, path, sizeof(path));
|
core_info_get_custom_config(core.UTF8String, path, sizeof(path));
|
||||||
|
|
||||||
if (![[NSFileManager defaultManager] copyItemAtPath:BOXSTRING(g_defaults.config_path) toPath:BOXSTRING(path) error:nil])
|
if (g_defaults.config_path[0] != '\0' && path[0] != '\0')
|
||||||
RARCH_WARN("Could not create custom config at %s", path);
|
{
|
||||||
|
if (!copy_config(g_defaults.config_path, path))
|
||||||
|
{
|
||||||
|
RARCH_WARN("Could not create custom config at %s.", path);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[weakSelf.navigationController popViewControllerAnimated:YES];
|
[weakSelf.navigationController popViewControllerAnimated:YES];
|
||||||
|
|
|
@ -48,7 +48,6 @@ const void* apple_get_frontend_settings(void);
|
||||||
|
|
||||||
|
|
||||||
@property (nonatomic) NSString* configDirectory; // e.g. /var/mobile/Documents/.RetroArch
|
@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* coreDirectory; // e.g. /Applications/RetroArch.app/modules
|
||||||
|
|
||||||
@property (nonatomic) NSString* documentsDirectory; // e.g. /var/mobile/Documents
|
@property (nonatomic) NSString* documentsDirectory; // e.g. /var/mobile/Documents
|
||||||
|
|
|
@ -201,7 +201,7 @@ static void handle_touch_event(NSArray* touches)
|
||||||
self.systemDirectory = [self.documentsDirectory stringByAppendingPathComponent:@".RetroArch"];
|
self.systemDirectory = [self.documentsDirectory stringByAppendingPathComponent:@".RetroArch"];
|
||||||
|
|
||||||
self.configDirectory = self.systemDirectory;
|
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"];
|
self.coreDirectory = [NSBundle.mainBundle.bundlePath stringByAppendingPathComponent:@"modules"];
|
||||||
|
|
||||||
path = (const char*)self.documentsDirectory.UTF8String;
|
path = (const char*)self.documentsDirectory.UTF8String;
|
||||||
|
|
Loading…
Reference in New Issue