Re: Open Resource File with Cocoa Path
Re: Open Resource File with Cocoa Path
- Subject: Re: Open Resource File with Cocoa Path
- From: Rainer Brockerhoff <email@hidden>
- Date: Wed, 10 Apr 2002 22:12:34 -0300
>
Date: Wed, 10 Apr 2002 13:54:21 -0500
>
From: Donald Brown <email@hidden>
>
>
I need to be able to import data from a legacy file, and it includes some
>
data in a resource. Anyone have any code to open a resource file?
>
>
As near as I can tell, I have to parse the path myself, calling
>
FSMakeFSRefUnicode on each portion to build up an FSRef, which I pass to
>
FSpOpenResFile. It can't be that screwy, can it?
It's not. Do something like this:
FSRef ref;
NSString* theFilePath; // put your full path into this
if (FSPathMakeRef([theFilePath fileSystemRepresentation,&ref,NULL)==noErr) {
short res = FSOpenResFile(&ref,fsRdPerm);
if (ResError()==noErr) {
// now use the routines in Resources.h
// to read resources...
CloseResFile(res);
}
}
HTH,
--
Rainer Brockerhoff <email@hidden>
Belo Horizonte, Brazil
"I love deadlines. I love the whooshing noise they make as they go by" (Douglas Adams)
http://www.brockerhoff.net/ (updated Feb. 2002)
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.