本文整理匯總了C++中CFBundleCopyResourceURL函數的典型用法代碼示例。如果您正苦於以下問題:C++ CFBundleCopyResourceURL函數的具體用法?C++ CFBundleCopyResourceURL怎麽用?C++ CFBundleCopyResourceURL使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了CFBundleCopyResourceURL函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: hu_XMLLoad
/*************************************************************************
*
* hu_XMLLoad( inResourceName, inResourceExtension )
*
* Purpose: Load a resource( XML ) file into a CFPropertyListRef
*
* Inputs: inResourceName - name of the resource file
* inResourceExtension - extension of the resource file
*
* Returns: CFPropertyListRef - the data
*/
static CFPropertyListRef hu_XMLLoad(CFStringRef inResourceName, CFStringRef inResourceExtension) {
CFURLRef resFileCFURLRef;
CFPropertyListRef tCFPropertyListRef = NULL;
// check the main (application) bundle
resFileCFURLRef = CFBundleCopyResourceURL(CFBundleGetMainBundle(), inResourceName, inResourceExtension, NULL);
if ( !resFileCFURLRef ) {
// check this specific (HID_Utilities framework) bundle
CFBundleRef tCFBundleRef = CFBundleGetBundleWithIdentifier(CFSTR("com.apple.HID_Utilities"));
if ( tCFBundleRef ) {
resFileCFURLRef = CFBundleCopyResourceURL( tCFBundleRef, inResourceName, inResourceExtension, NULL );
}
}
if ( !resFileCFURLRef ) {
// check bundles already loaded or otherwise known to the current process
CFArrayRef tCFArrayRef = CFBundleGetAllBundles();
CFIndex idx, cnt = CFArrayGetCount(tCFArrayRef);
for ( idx = 0; idx < cnt; idx++ ) {
CFBundleRef tCFBundleRef = (CFBundleRef) CFArrayGetValueAtIndex(tCFArrayRef, idx) ;
if ( tCFBundleRef ) {
resFileCFURLRef = CFBundleCopyResourceURL( tCFBundleRef, inResourceName, inResourceExtension, NULL );
if ( resFileCFURLRef ) {
break;
}
}
}
}
if ( resFileCFURLRef ) {
tCFPropertyListRef = hu_LoadFromXMLFile(resFileCFURLRef);
CFRelease(resFileCFURLRef);
}
return (tCFPropertyListRef);
} // hu_XMLLoad
示例2: RemotePluginClient
RemoteVSTClient::RemoteVSTClient(CFBundleRef bundle, audioMasterCallback theMaster, AEffect *theEffect, bool showGUI) :
RemotePluginClient(theMaster, theEffect)
{
m_bundle = bundle;
m_audioMaster = theMaster;
pid_t child;
SInt32 errorCode;
CFDataRef data;
CFURLRef configUrl = CFBundleCopyResourceURL(bundle, CFSTR("config"), CFSTR("plist"), NULL);
if (configUrl == 0) {
return;
}
CFURLCreateDataAndPropertiesFromResource(kCFAllocatorDefault, configUrl, &data, NULL, NULL, &errorCode);
m_props = (CFDictionaryRef) CFPropertyListCreateFromXMLData( kCFAllocatorDefault, data, kCFPropertyListImmutable, NULL);
std::string dllName(CFStringGetCStringPtr(get_path_prop(CFSTR("plugin-name")), NULL));
std::string arg = dllName + "," + getFileIdentifiers();
if (showGUI) arg = "-g " + arg;
const char *argStr = arg.c_str();
CFURLRef server_url = CFBundleCopyResourceURL(m_bundle, CFSTR("dssi-vst-server.exe"), CFSTR("so"), NULL);
if (server_url != NULL) {
CFStringRef server_path = CFURLCopyFileSystemPath(server_url, kCFURLPOSIXPathStyle);
if (server_path != NULL) {
const char *c_server_path = CFStringGetCStringPtr(server_path, NULL);
CFStringRef wine_path = (CFStringRef) CFDictionaryGetValue(m_props, CFSTR("wine-path"));
if (wine_path != NULL) {
const char *c_wine_path = CFStringGetCStringPtr(wine_path, NULL);
std::cerr << "RemoteVSTClient: executing " << c_server_path << "\n";
// if no dispaly environment guess...
// setenv("DISPLAY", ":0", 0);
setenv("DYLD_FALLBACK_LIBRARY_PATH", "/usr/X11/lib:/usr/lib", 0);
if ((child = fork()) < 0) {
cleanup();
throw((std::string)"Fork failed");
} else if (child == 0) { // child process
if (execlp(c_wine_path, "wine", c_server_path, argStr, NULL)) {
perror("Exec failed");
exit(1);
}
}
syncStartup();
return;
}
}
}
cleanup();
throw((std::string)"Failed to find dssi-vst-server executable");
return;
}
示例3: _bTrace_
// ---------------------------------------------------------------------------
// A PLACER DANS STYLEMGR
// ------------
bool bMacMapType::make_style(){
_bTrace_("bMacMapType::make_style",false);
char path[PATH_MAX];
CFURLRef url;
switch(_kind){
case kBaseKindPoint:
url=CFBundleCopyResourceURL(CFBundleGetMainBundle(),CFSTR("default_point_style"),CFSTR("xml"),NULL);
break;
case kBaseKindPolyline:
url=CFBundleCopyResourceURL(CFBundleGetMainBundle(),CFSTR("default_line_style"),CFSTR("xml"),NULL);
break;
case kBaseKindText:
url=CFBundleCopyResourceURL(CFBundleGetMainBundle(),CFSTR("default_text_style"),CFSTR("xml"),NULL);
break;
case kBaseKindPolygon:
url=CFBundleCopyResourceURL(CFBundleGetMainBundle(),CFSTR("default_surf_style"),CFSTR("xml"),NULL);
break;
case kBaseKindRaster:
url=CFBundleCopyResourceURL(CFBundleGetMainBundle(),CFSTR("default_raster_style"),CFSTR("xml"),NULL);
break;
default:
_te_("bad type kind "+_kind);
return(false);
break;
}
if(!url){
_te_("url == NULL");
return(false);
}
CFStringRef cfs=CFURLCopyFileSystemPath(url,kCFURLPOSIXPathStyle);
CFRelease(url);
CFStringGetCString(cfs,path,PATH_MAX,kCFStringEncodingMacRoman);
CFRelease(cfs);
void* buffer;
int sz;
bStdFile stl(path,"r");
if(stl.status()){
_te_("stl.status()="+stl.status());
return(false);
}
stl.mount((char**)&buffer,&sz);
_bse.set_param("styles","default.xml",buffer,sz);
free(buffer);
return(true);
}
示例4: getFrameworkFromBundle
static string getFrameworkFromBundle()
{
// Attempt to locate the Firebird.framework bundle
CFBundleRef fbFramework = CFBundleGetBundleWithIdentifier(CFSTR(DARWIN_FRAMEWORK_ID));
if (fbFramework)
{
CFURLRef msgFileUrl = CFBundleCopyResourceURL(fbFramework,
CFSTR(DARWIN_GEN_DIR), NULL, NULL);
if (msgFileUrl)
{
CFStringRef msgFilePath = CFURLCopyFileSystemPath(msgFileUrl,
kCFURLPOSIXPathStyle);
if (msgFilePath)
{
char file_buff[MAXPATHLEN];
if (CFStringGetCString(msgFilePath, file_buff, MAXPATHLEN,
kCFStringEncodingMacRoman))
{
string dir = file_buff;
dir += PathUtils::dir_sep;
return dir;
}
}
}
}
// No luck
return "";
}
示例5: ios_open_from_bundle
static FILE* ios_open_from_bundle(const char path[], const char* perm) {
// Get a reference to the main bundle
CFBundleRef mainBundle = CFBundleGetMainBundle();
// Get a reference to the file's URL
CFStringRef pathRef = CFStringCreateWithCString(NULL, path, kCFStringEncodingUTF8);
CFURLRef imageURL = CFBundleCopyResourceURL(mainBundle, pathRef, NULL, NULL);
CFRelease(pathRef);
if (!imageURL) {
return nullptr;
}
// Convert the URL reference into a string reference
CFStringRef imagePath = CFURLCopyFileSystemPath(imageURL, kCFURLPOSIXPathStyle);
CFRelease(imageURL);
// Get the system encoding method
CFStringEncoding encodingMethod = CFStringGetSystemEncoding();
// Convert the string reference into a C string
const char *finalPath = CFStringGetCStringPtr(imagePath, encodingMethod);
FILE* fileHandle = fopen(finalPath, perm);
CFRelease(imagePath);
return fileHandle;
}
示例6: fopen
FILE* fopen (const char *filename, const char *mode) {
#ifdef HX_MACOS
FILE *result = ::fopen (filename, "rb");
if (!result) {
CFStringRef str = CFStringCreateWithCString (NULL, filename, kCFStringEncodingUTF8);
CFURLRef path = CFBundleCopyResourceURL (CFBundleGetMainBundle (), str, NULL, NULL);
CFRelease (str);
if (path) {
str = CFURLCopyPath (path);
CFIndex maxSize = CFStringGetMaximumSizeForEncoding (CFStringGetLength (str), kCFStringEncodingUTF8);
char *buffer = (char *)malloc (maxSize);
if (CFStringGetCString (str, buffer, maxSize, kCFStringEncodingUTF8)) {
result = ::fopen (buffer,"rb");
free (buffer);
}
CFRelease (str);
CFRelease (path);
}
}
return result;
#else
return ::fopen (filename, mode);
#endif
}
示例7: UnloadBundle
void UnloadBundle(CFBundleRef theBundle)
{
/*get bundle resource and convert from xml to propertylist struct so we can look for revdontunload attribute and not unload- necessary for external
that interface with Cocoa*/
Boolean dontunload = False;
CFPropertyListRef tCFPropertyListRef = NULL;
short resrefnum = CFBundleOpenBundleResourceMap (theBundle );
CFURLRef resFileCFURLRef = CFBundleCopyResourceURL(theBundle,CFSTR("revinfo"),CFSTR("plist"),NULL);
CFDataRef resCFDataRef;
if (resFileCFURLRef && CFURLCreateDataAndPropertiesFromResource(kCFAllocatorDefault,resFileCFURLRef,&resCFDataRef,nil,nil,nil))
{
if (resCFDataRef)
{
CFStringRef errorString;
tCFPropertyListRef = CFPropertyListCreateFromXMLData(kCFAllocatorDefault,resCFDataRef,kCFPropertyListImmutable,&errorString);
CFRelease(resCFDataRef);
}
}
if (tCFPropertyListRef)
{
if (CFDictionaryGetValueIfPresent((CFDictionaryRef)tCFPropertyListRef,CFSTR("revdontunload"),NULL))
dontunload = True;
}
if (resFileCFURLRef)
CFRelease(resFileCFURLRef);
CFBundleCloseBundleResourceMap (theBundle,resrefnum);
if (theBundle && !dontunload)
{
CFBundleUnloadExecutable(theBundle);
CFRelease(theBundle);
}
}
示例8: xml_load
// ---------------------------------
// Load the element strings from the given resource (XML) file into a CFPropertyListRef
static CFPropertyListRef xml_load(const CFStringRef pResourceName,const CFStringRef pResourceExtension)
{
CFPropertyListRef tCFPropertyListRef = NULL;
CFURLRef resFileCFURLRef = CFBundleCopyResourceURL(CFBundleGetMainBundle(), pResourceName, pResourceExtension, NULL);
if (NULL != resFileCFURLRef)
{
CFDataRef resCFDataRef;
if (CFURLCreateDataAndPropertiesFromResource(kCFAllocatorDefault, resFileCFURLRef, &resCFDataRef, nil, nil, nil))
{
if (NULL != resCFDataRef)
{
CFStringRef errorString;
tCFPropertyListRef = CFPropertyListCreateFromXMLData(kCFAllocatorDefault, resCFDataRef, kCFPropertyListImmutable, &errorString);
if (NULL == tCFPropertyListRef)
CFShow(errorString);
CFRelease(resCFDataRef);
}
}
CFRelease(resFileCFURLRef);
}
return tCFPropertyListRef;
}
示例9: getPropertyList
static CFPropertyListRef getPropertyList()
{
CFDataRef xmlData;
CFStringRef error;
CFPropertyListRef propertyList;
CFBundleRef appBundle;
CFURLRef myRef;
// locate the starter's bundle:
appBundle = CFBundleGetMainBundle();
// get a URL for the named resource
myRef = CFBundleCopyResourceURL(appBundle, CFSTR(RSRCNAME),
NULL, NULL);
if (myRef == NULL) {
return NULL;
}
// Load the XML data using its URL.
CFURLCreateDataAndPropertiesFromResource(kCFAllocatorDefault, myRef,
&xmlData, NULL, NULL, NULL);
// convert to a Property List
propertyList = CFPropertyListCreateFromXMLData(kCFAllocatorDefault, xmlData,
kCFPropertyListImmutable,
&error);
if (error != NULL) {
return NULL;
}
return propertyList;
}
示例10: path_to_file
char const* path_to_file(CFStringRef file, CFStringRef extension)
{
// Get a reference to the main bundle
CFBundleRef mainBundle = CFBundleGetMainBundle();
if (mainBundle == NULL) {
return NULL;
}
// Get a reference to the file's URL
CFURLRef imageURL = CFBundleCopyResourceURL(mainBundle,
file,
extension,
NULL);
if (imageURL == NULL) {
return NULL;
}
// Convert the URL reference into a string reference
CFStringRef imagePath = CFURLCopyFileSystemPath(imageURL,
kCFURLPOSIXPathStyle);
// Get the system encoding method
CFStringEncoding encodingMethod = CFStringGetSystemEncoding();
// Convert the string reference into a C string
const char *path = CFStringGetCStringPtr(imagePath, encodingMethod);
return path;
}
示例11: CFBundleCopyResourceURL
//----------------------------------------------------------------------------//
const char* CEGuiBaseApplication::getDataPathPrefix() const
{
static char dataPathPrefix[PATH_MAX];
#ifdef __APPLE__
CFURLRef datafilesURL = CFBundleCopyResourceURL(CFBundleGetMainBundle(),
CFSTR("datafiles"),
0, 0);
CFURLGetFileSystemRepresentation(datafilesURL, true,
reinterpret_cast<UInt8*>(dataPathPrefix),
PATH_MAX);
CFRelease(datafilesURL);
#else
char* envDataPath = 0;
// get data path from environment var
envDataPath = getenv(DATAPATH_VAR_NAME);
// set data path prefix / base directory. This will
// be either from an environment variable, or from
// a compiled in default based on original configure
// options
if (envDataPath != 0)
strcpy(dataPathPrefix, envDataPath);
else
strcpy(dataPathPrefix, CEGUI_SAMPLE_DATAPATH);
#endif
return dataPathPrefix;
}
示例12: CreateScene
int CreateScene() {
CFURLRef balls_dat_url = CFBundleCopyResourceURL(CFBundleGetMainBundle(), CFSTR("balls"), CFSTR("dat"),NULL);
char filename[1024];
CFURLGetFileSystemRepresentation(balls_dat_url, true, (UInt8*)filename, (CFIndex)sizeof(filename));
CFRelease(balls_dat_url);
global_scene = rt_newscene();
rt_initialize();
if ( readmodel(filename, global_scene) != 0 ) {
rt_finalize();
return -1;
}
// need these early for create_graphics_window() so grab these here...
scenedef *scene = (scenedef *) global_scene;
get_screen_resolution(&global_xsize, &global_ysize);
// scene->hres and scene->vres should be equal to screen resolution
scene->hres = global_xwinsize = global_xsize;
scene->vres = global_ywinsize = global_ysize;
return 0;
}
示例13: _bs_main_bundle_bs_path
static inline const char *
_bs_main_bundle_bs_path(void)
{
static bool done = false;
static char *path = NULL;
/* XXX not thread-safe */
if (!done) {
CFBundleRef bundle;
done = true;
bundle = CFBundleGetMainBundle();
if (bundle != NULL) {
CFURLRef url;
url = CFBundleCopyResourceURL(bundle, CFSTR("BridgeSupport"),
NULL, NULL);
if (url != NULL) {
CFStringRef str = CFURLCopyPath(url);
path = (char *)malloc(sizeof(char) * PATH_MAX);
ASSERT_ALLOC(path);
CFStringGetFileSystemRepresentation(str, path, PATH_MAX);
CFRelease(str);
CFRelease(url);
}
}
}
return path;
}
示例14: SQLite3StatementCreateWithBundleResource
inline SQLite3StatementRef SQLite3StatementCreateWithBundleResource(SQLite3ConnectionRef connection, CFBundleRef bundle, CFStringRef type, CFStringRef name, CFStringRef subdir) {
SQLite3StatementRef statement = NULL;
if (connection) {
SInt32 errorCode = 0;
CFDictionaryRef properties = NULL;
CFDataRef data = NULL;
CFURLRef url = CFBundleCopyResourceURL(bundle, name, type, subdir);
if (url) {
if (CFURLCreateDataAndPropertiesFromResource(connection->allocator, url, &data, &properties, NULL, &errorCode)) {
CFStringRef sql = CFStringCreateWithBytes(connection->allocator, CFDataGetBytePtr(data), CFDataGetLength(data), kCFStringEncodingUTF8, 0);
if (sql) {
statement = SQLite3StatementCreate(connection, sql);
CFRelease(sql);
}
CFRelease(data);
if (properties)
CFRelease(properties);
} else {
// TODO: Error
}
CFRelease(url);
}
}
return statement;
}
示例15: GetThePoofImage
static CGImageRef GetThePoofImage()
{
CGDataProviderRef provider;
CFStringRef fileName = NULL;
CGImageRef image = NULL;
CFURLRef url = NULL;
CFBundleRef appBundle = CFBundleGetMainBundle();
if ( appBundle == NULL ) goto Bail;
fileName = CFStringCreateWithCString( NULL, "ToolbarPoof.png", kCFStringEncodingASCII ); // ToolbarPoof.png is in our Resources directory within the bundle
if ( fileName == NULL ) goto Bail;
url = CFBundleCopyResourceURL( appBundle, fileName, NULL, NULL );
if ( url == NULL ) goto Bail;
provider = CGDataProviderCreateWithURL( url );
image = CGImageCreateWithPNGDataProvider( provider, NULL, false, kCGRenderingIntentDefault );
CGDataProviderRelease( provider );
Bail:
if ( fileName != NULL ) CFRelease( fileName );
if ( url != NULL ) CFRelease( url );
return( image );
}