How to get own plugin path on C++

Discussion in 'Mac Programming' started by Tank2005, Apr 24, 2009.

  1. Tank2005 macrumors newbie

    Joined:
    Apr 24, 2009
    #1
    I'm developing Carbon Bundle Application now.

    And I'm looking into the way of getting an own file path. but, even if the .app file of the ringback application is obtainable, an own .bundle file is unacquirable by the following ways.

    Code:
    ProcessSerialNumber currentProcess = {0, kCurrentProcess};
    GetProcessBundleLocation(&currentProcess, &fsRef);
    If there is optimal way, please let me know.
     
  2. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #2
    Try using CFBundleGetBundleWithIdentifier() to get your plugin's bundle, then any of the CFBundle functions can be used to get a file, such as CFBundleCopyResourceURL().
     
  3. Tank2005 thread starter macrumors newbie

    Joined:
    Apr 24, 2009
    #3
    I have obtained it by the following code. Many thanks!

    Code:
    CFBundleRef r1 = CFBundleGetBundleWithIdentifier(CFSTR("com.apple.myplugin"));
    CFURLRef u1 = CFBundleCopyBundleURL(r1);
    CFStringRef p1 = CFURLCopyFileSystemPath(u1, kCFURLPOSIXPathStyle);
    
    CFRelease(p1);
    CFRelease(u1);
    CFRelease(r1);
     
  4. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #4
    Just one more thing: the value returned by CFBundleGetBundleWithIdentifier() shouldn't be released because it follows the Get Rule.
     

Share This Page