mirror of
https://github.com/libretro/RetroArch
synced 2025-02-19 12:41:00 +00:00
(iOS) Refactor out path_make_and_check_directory
This commit is contained in:
parent
c51d5bcd57
commit
a6e012e747
@ -53,7 +53,6 @@ extern void apple_run_core(RAModuleInfo* core, const char* file);
|
||||
|
||||
// utility.m
|
||||
extern void apple_display_alert(NSString* message, NSString* title);
|
||||
extern bool path_make_and_check_directory(const char* path, mode_t mode, int amode);
|
||||
extern NSString* objc_get_value_from_config(config_file_t* config, NSString* name, NSString* defaultValue);
|
||||
|
||||
// frontend/platform/platform_apple.c
|
||||
|
@ -54,15 +54,6 @@ NSString* objc_get_value_from_config(config_file_t* config, NSString* name, NSSt
|
||||
return result;
|
||||
}
|
||||
|
||||
// Ensures a directory exists and has correct permissions
|
||||
bool path_make_and_check_directory(const char* path, mode_t mode, int amode)
|
||||
{
|
||||
if (!path_is_directory(path) && mkdir(path, mode) != 0)
|
||||
return false;
|
||||
|
||||
return access(path, amode) == 0;
|
||||
}
|
||||
|
||||
#ifdef IOS
|
||||
|
||||
char* ios_get_rarch_system_directory()
|
||||
|
@ -159,14 +159,20 @@ static void handle_touch_event(NSArray* touches)
|
||||
self.configDirectory = self.systemDirectory;
|
||||
self.globalConfigFile = [NSString stringWithFormat:@"%@/retroarch.cfg", self.configDirectory];
|
||||
self.coreDirectory = [NSBundle.mainBundle.bundlePath stringByAppendingPathComponent:@"modules"];
|
||||
|
||||
if (!path_make_and_check_directory(self.documentsDirectory.UTF8String, 0755, R_OK | W_OK | X_OK))
|
||||
|
||||
const char *path = self.documentsDirectory.UTF8String;
|
||||
path_mkdir(path);
|
||||
if (access(path, 0755) != 0)
|
||||
apple_display_alert([NSString stringWithFormat:@"Failed to create or access base directory: %@", self.documentsDirectory], 0);
|
||||
else if (!path_make_and_check_directory(self.systemDirectory.UTF8String, 0755, R_OK | W_OK | X_OK))
|
||||
apple_display_alert([NSString stringWithFormat:@"Failed to create or access system directory: %@", self.systemDirectory], 0);
|
||||
else
|
||||
[self beginBrowsingForFile];
|
||||
|
||||
else
|
||||
{
|
||||
path = self.systemDirectory.UTF8String;
|
||||
path_mkdir(path);
|
||||
if (access(path, 0755) != 0)
|
||||
apple_display_alert([NSString stringWithFormat:@"Failed to create or access system directory: %@", self.systemDirectory], 0);
|
||||
else
|
||||
[self beginBrowsingForFile];
|
||||
}
|
||||
|
||||
// Warn if there are no cores present
|
||||
if (apple_get_modules().count == 0)
|
||||
|
@ -667,8 +667,10 @@ void path_resolve_realpath(char *buf, size_t size)
|
||||
|
||||
static bool path_mkdir_norecurse(const char *dir)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
int ret = _mkdir(dir);
|
||||
#elif defined(IOS)
|
||||
int ret = mkdir(dir, 0755);
|
||||
#else
|
||||
int ret = mkdir(dir, 0750);
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user