Re: FSSpec --> OSX Path NSString
Re: FSSpec --> OSX Path NSString
- Subject: Re: FSSpec --> OSX Path NSString
- From: Nick Zitzmann <email@hidden>
- Date: Wed, 12 Mar 2003 04:26:07 -0800
On Wednesday, March 12, 2003, at 03:37 AM, Flemming Bengtsson wrote:
I'm writing an application that needs to convert an OS9 FSSpec
structure to an OSX path NSString.
I can't see anyway to do this, hope I'm wrong...
You are. <;*) Here's the upshot (note: typed in Mail, untested, use at
your own risk, etc.):
FSSpec spec;
FSRef ref;
NSString string;
char cString[PATH_MAX]; // to get PATH_MAX, include limits.h
OSStatus err;
if ((err = FSpMakeFSRef(&spec, &ref)) == noErr) // translate the FSSpec
into an FSRef
{
FSRefMakePath(&ref, cString, PATH_MAX); // translate the FSRef into
a path
string = [NSString stringWithUTF8String:cString]; // translate the
C string into an NSString
}
If err is noErr, then "string" should hold the path...
Nick Zitzmann
AIM/iChat: dragonsdontsleep
Check out my software page:
http://dreamless.home.attbi.com/
Smile! It confuses people!
_______________________________________________
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.