Re: [Cocoa] How convert ":Developer:Private:jam" into a path POSIX-style
Re: [Cocoa] How convert ":Developer:Private:jam" into a path POSIX-style
- Subject: Re: [Cocoa] How convert ":Developer:Private:jam" into a path POSIX-style
- From: Stefan Werner <email@hidden>
- Date: Fri, 20 Apr 2007 09:37:03 -0700
On 20.04.2007, at 08:48, donaldo donaldo wrote:
Thx
My code :
char path[500] = "mypath";
CFStringRef urlString = (NSString *) path;
CFURLRef url = CFURLCreateWithFileSystemPath(kCFAllocatorDefault,
urlString,
kCFURLHFSPathStyle, YES);
CFStringRef resultString = CFURLCopyFileSystemPath
(url,kCFURLPOSIXPathStyle);
NSString* myString = (NSString*) resultString;
The second line should read:
CFStringRef urlString = CFStringWithCString(kCFAllocatorDefault,
path, kCFStringEncodingMacRoman);
and then you must later release it with CFRelease(urlString);
Replace the kCFStringEncodingMacRoman with the proper encoding if
your string is not MacRoman encoded. But in general, most if not all
Mac OS functions that deal with HFS Paths use MacRoman encoding on
Western versions of the OS.
Stefan
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden