5 #ifndef __getpluginbundle__ 6 #define __getpluginbundle__ 13 #include <CoreFoundation/CFBundle.h> 17 static CFBundleRef GetPluginBundle ()
19 CFBundleRef pluginBundle = 0;
21 if (dladdr ((
const void*)GetPluginBundle, &info))
26 name.assign (info.dli_fname);
27 for (
int i = 0; i < 3; i++)
29 size_t delPos = name.find_last_of (
'/');
30 if (delPos == std::string::npos)
32 fprintf (stdout,
"Could not determine bundle location.\n");
35 name.erase (delPos, name.length () - delPos);
37 CFURLRef bundleUrl = CFURLCreateFromFileSystemRepresentation (0, (
const UInt8*)name.c_str (), name.length (),
true);
40 pluginBundle = CFBundleCreate (0, bundleUrl);
41 CFRelease (bundleUrl);
54 #endif // __getpluginbundle__