(Apple) Reimplement CFSearchPathForDirectories

This commit is contained in:
Twinaphex 2014-10-17 17:00:57 +02:00
parent defdd65fae
commit f704097573
3 changed files with 13 additions and 11 deletions

View File

@ -134,17 +134,12 @@ static char** waiting_argv;
apple_platform = self;
char support_path_buf[PATH_MAX + 1];
CFArrayRef array = CFSearchPathForDirectoriesInDomains(CFApplicationSupportDirectory, CFUserDomainMask, YES);
CFStringRef support_path = CFBridgingRetain(CFArrayGetValueAtIndex(array, 0));
CFStringGetCString(support_path, support_path_buf, sizeof(support_path_buf), kCFStringEncodingUTF8);
CFSearchPathForDirectoriesInDomains(CFApplicationSupportDirectory, CFUserDomainMask, YES, support_path_buf, sizeof(support_path_buf));
fill_pathname_join(g_defaults.core_dir, NSBundle.mainBundle.bundlePath.UTF8String, "Contents/Resources/modules", sizeof(g_defaults.core_dir));
fill_pathname_join(g_defaults.menu_config_dir, support_path_buf, "RetroArch", sizeof(g_defaults.menu_config_dir));
fill_pathname_join(g_defaults.config_path, g_defaults.menu_config_dir, "retroarch.cfg", sizeof(g_defaults.config_path));
CFRelease(support_path);
CFRelease(array);
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
[self.window setCollectionBehavior:[self.window collectionBehavior] | NSWindowCollectionBehaviorFullScreenPrimary];

View File

@ -59,7 +59,7 @@ typedef enum
CFAllDomainsMask = 0x0ffff // all domains: all of the above and future items
} CFDomainMask;
CFArrayRef CFSearchPathForDirectoriesInDomains(unsigned flags,
unsigned domain_mask, BOOL expand_tilde);
void CFSearchPathForDirectoriesInDomains(unsigned flags,
unsigned domain_mask, BOOL expand_tilde, char *buf, size_t sizeof_buf);
#endif

View File

@ -14,11 +14,18 @@
*/
#include <CoreFoundation/CFArray.h>
#include <CoreFoundation/CFString.h>
#import <Foundation/NSPathUtilities.h>
#include "CFExtensions.h"
CFArrayRef CFSearchPathForDirectoriesInDomains(unsigned flags,
unsigned domain_mask, BOOL expand_tilde)
void CFSearchPathForDirectoriesInDomains(unsigned flags,
unsigned domain_mask, BOOL expand_tilde,
char *buf, size_t sizeof_buf)
{
return CFBridgingRetain(NSSearchPathForDirectoriesInDomains(flags, domain_mask, expand_tilde));
CFArrayRef array = CFBridgingRetain(NSSearchPathForDirectoriesInDomains(
flags, domain_mask, expand_tilde));
CFStringRef path = CFBridgingRetain(CFArrayGetValueAtIndex(array, 0));
CFStringGetCString(path, buf, sizeof_buf, kCFStringEncodingUTF8);
CFRelease(path);
CFRelease(array);
}