After Mike K pointed me in the right direction, I was able to retrieve the path to a file in an application bundle with the following code.
// Get a reference to the main bundle
CFBundleRef mainBundle = CFBundleGetMainBundle();
// Get a reference to the file's URL
CFURLRef imageURL = CFBundleCopyResourceURL(mainBundle, CFSTR("MyImage"), CFSTR("bmp"), 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);
fprintf(stderr, "File is located at %s
", path);
This seems to be a bit longer than it needs to be, but at least it works!
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…