Re: converting resource filename to absolute pathname
Re: converting resource filename to absolute pathname
- Subject: Re: converting resource filename to absolute pathname
- From: Chris Espinosa <email@hidden>
- Date: Fri, 30 Sep 2005 01:07:20 -0700
On Sep 29, 2005, at 9:00 PM, Kaveh Kardan wrote:
XCode automagically converts pathnames in order to find resource files
in a project.
Xcode actually does nothing of the sort. It places resources into
executable bundles in the conventional place, the Resources directory.
Finding resources there is the job of code at runtime, usually the
Cocoa or Carbon frameworks, both of which ask CFBundle.
I need to pass a pathname string to an in-house dynamic library to
load. Though the file has been added to the project's resources, the
library is not able to find it, perhaps because it has not been
compiled with XCode.
More likely that the library is expecting the path to be either
absolute or relative to its own bundle.
Is there a way of converting the pathname to an absolute path before
passing it to the library? Is there a better solution to this?
Well, try getting the main bundle with CFBundleGetMainBundle, then from
that get its Resources directory with CFBundleCopyResourceURL, then use
the appropriate CFURL call to turn that into an absolute path of the
form your library wants, tacking on the name of the resource file at
the end.
http://developer.apple.com/documentation/CoreFoundation/Reference/
CFBundleRef/Reference/chapter_2.1_section_4.html#//apple_ref/doc/uid/
20001191-DontLinkChapterID_1-F12795
Chris
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden