(OSX) Create wrapper function around NSSearchPathForDirectoriesInDomains

and create surrogate enums
This commit is contained in:
Twinaphex 2014-10-16 21:02:22 +02:00
parent 787881a2ac
commit f1ba2e2dc5
2 changed files with 51 additions and 1 deletions

View File

@ -22,6 +22,50 @@
#include <CoreLocation/CoreLocation.h>
#endif
typedef enum
{
CFApplicationDirectory = 1, // supported applications (Applications)
CFDemoApplicationDirectory, // unsupported applications, demonstration versions (Demos)
CFDeveloperApplicationDirectory, // developer applications (Developer/Applications). DEPRECATED - there is no one single Developer directory.
CFAdminApplicationDirectory, // system and network administration applications (Administration)
CFLibraryDirectory, // various documentation, support, and configuration files, resources (Library)
CFDeveloperDirectory, // developer resources (Developer) DEPRECATED - there is no one single Developer directory.
CFUserDirectory, // user home directories (Users)
CFDocumentationDirectory, // documentation (Documentation)
CFDocumentDirectory, // documents (Documents)
CFCoreServiceDirectory, // location of CoreServices directory (System/Library/CoreServices)
CFAutosavedInformationDirectory = 11, // location of autosaved documents (Documents/Autosaved)
CFDesktopDirectory = 12, // location of user's desktop
CFCachesDirectory = 13, // location of discardable cache files (Library/Caches)
CFApplicationSupportDirectory = 14, // location of application support files (plug-ins, etc) (Library/Application Support)
CFDownloadsDirectory = 15, // location of the user's "Downloads" directory
CFInputMethodsDirectory = 16, // input methods (Library/Input Methods)
CFMoviesDirectory = 17, // location of user's Movies directory (~/Movies)
CFMusicDirectory = 18, // location of user's Music directory (~/Music)
CFPicturesDirectory = 19, // location of user's Pictures directory (~/Pictures)
CFPrinterDescriptionDirectory = 20, // location of system's PPDs directory (Library/Printers/PPDs)
CFSharedPublicDirectory = 21, // location of user's Public sharing directory (~/Public)
CFPreferencePanesDirectory = 22, // location of the PreferencePanes directory for use with System Preferences (Library/PreferencePanes)
CFApplicationScriptsDirectory = 23, // location of the user scripts folder for the calling application (~/Library/Application Scripts/code-signing-id)
CFItemReplacementDirectory = 99, // For use with NSFileManager's URLForDirectory:inDomain:appropriateForURL:create:error:
CFAllApplicationsDirectory = 100, // all directories where applications can occur
CFAllLibrariesDirectory = 101, // all directories where resources can occur
CFTrashDirectory = 102 // location of Trash directory
} CFSearchPathDirectory;
typedef enum
{
CFUserDomainMask = 1, // user's home directory --- place to install user's personal items (~)
CFLocalDomainMask = 2, // local to the current machine --- place to install items available to everyone on this machine (/Library)
CFNetworkDomainMask = 4, // publically available location in the local area network --- place to install items available on the network (/Network)
CFSystemDomainMask = 8, // provided by Apple, unmodifiable (/System)
CFAllDomainsMask = 0x0ffff // all domains: all of the above and future items
} CFDomainMask;
CFArrayRef CFSearchPathForDirectoriesInDomains(unsigned flags,
unsigned domain_mask, BOOL expand_tilde);
@interface RAGameView : NSView
#ifdef HAVE_LOCATION
<CLLocationManagerDelegate>

View File

@ -98,6 +98,12 @@ static void* const associated_core_key = (void*)&associated_core_key;
@end
CFArrayRef CFSearchPathForDirectoriesInDomains(unsigned flags,
unsigned domain_mask, BOOL expand_tilde)
{
return CFBridgingRetain(NSSearchPathForDirectoriesInDomains(flags, domain_mask, expand_tilde));
}
static int waiting_argc;
static char** waiting_argv;
@ -133,7 +139,7 @@ static char** waiting_argv;
apple_platform = self;
char support_path_buf[PATH_MAX + 1];
CFArrayRef array = CFBridgingRetain(NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES));
CFArrayRef array = CFSearchPathForDirectoriesInDomains(CFApplicationSupportDirectory, CFUserDomainMask, YES);
CFStringRef support_path = CFBridgingRetain(CFArrayGetValueAtIndex(array, 0));
CFStringGetCString(support_path, support_path_buf, sizeof(support_path_buf), kCFStringEncodingUTF8);