29 #include "nomlib/system/OSX/ResourcePath.hpp"
33 const std::string getBundleResourcePath (
const std::string& identifier )
35 char resources_path [ PATH_MAX ];
40 if ( identifier !=
"\0" )
42 CFStringRef identifier_ref;
44 identifier_ref = CFStringCreateWithCString (
nullptr, identifier.c_str(),
45 strlen ( identifier.c_str() )
48 bundle = CFBundleGetBundleWithIdentifier ( identifier_ref );
52 bundle = CFBundleGetMainBundle();
55 CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL ( bundle );
57 if ( ! CFURLGetFileSystemRepresentation ( resourcesURL,
true, ( uint8* ) resources_path, PATH_MAX ) )
59 NOM_LOG_ERR ( NOM,
"Could not obtain the bundle's Resources path." );
61 CFRelease ( resourcesURL );
66 CFRelease ( resourcesURL );
68 return resources_path;
71 #pragma clang diagnostic push
72 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
74 const std::string user_documents_path (
void )
77 OSType folderType = kDocumentsFolderType;
80 FSFindFolder ( kUserDomain, folderType, kCreateFolder, &ref );
82 FSRefMakePath ( &ref, (uint8*) &path, PATH_MAX );
84 return std::string ( path );
87 const std::string user_app_support_path (
void )
90 OSType folderType = kApplicationSupportFolderType;
93 FSFindFolder ( kUserDomain, folderType, kCreateFolder, &ref );
95 FSRefMakePath ( &ref, (uint8*) &path, PATH_MAX );
97 return std::string ( path );
100 #pragma clang diagnostic pop