1. Welcome to the new MacRumors forums. See our announcement and read our FAQ

C++ Bundle path

Discussion in 'Mac Programming' started by kcjones, Sep 14, 2008.

  1. macrumors newbie

    #1
    Hey Everyone,

    My question is how do I get the bundle path in c++. Something similar to:

    [[NSBundle mainBundle] pathForResource:mad:"image" ofType:mad:"png"]

    How do I get the full path of a resource in the Application bundle in char[].

    Thanks for your help!
     
  2. macrumors newbie

    #2
    Ok I've now got:

    Code:
    	CFBundleRef mainBundle = CFBundleGetMainBundle();
            CFURLRef resourcesURL = CFBundleCopyBundleURL(mainBundle);
    	
    	CFShow(resourcesURL); // prints full bundle path to console
    	
    	CFRelease(resourcesURL);
    
    
    How do I get the resourcesURL to a string and append something to it?
     
  3. macrumors newbie

    #3
    Don't worry about it I got it:

    Code:
            CFBundleRef mainBundle = CFBundleGetMainBundle();
            CFURLRef resourcesURL = CFBundleCopyBundleURL(mainBundle);
    	CFStringRef str = CFURLCopyFileSystemPath( resourcesURL, kCFURLPOSIXPathStyle );
    	CFRelease(resourcesURL);
    	char path[PATH_MAX];
    	
    	CFStringGetCString( str, path, FILENAME_MAX, kCFStringEncodingASCII );
    	CFRelease(str);
    	fprintf(stderr, path);
    
    
     

Share This Page