  | |  | Working with XML files/CFURL | Working with XML files/CFURL 2003-11-22 - By Bryan Pietrzak
Back On Nov 21, 2003, at 2:36 AM, m.b. wrote:
> Before I go asking for help on how to use that am I correct in > assuming that is the best method to get the CFURLRef for a file in my > filesystem and should I ask this elsewhere?
If you are on OS 9 or later:
Assuming you have an FSSpec:
FSRef fileRef; error = FSpMakeFSRef(&file, &fileRef); url = CFURLCreateFromFSRef (kCFAllocatorSystemDefault, &fileRef);
If you must support 8.6 (and therefore can't use FSRefs)
TextEncoding systemEncoding; Str255 fullpath; GetFullPathname(&file, fullpath); (ick, but what are you gonna do? this is like "mydrive:myfolder:myfile" if (UpgradeScriptInfoToTextEncoding == (void *) kUnresolvedCFragSymbolAddress) systemEncoding = kCFStringEncodingMacRoman; else UpgradeScriptInfoToTextEncoding (GetScriptManagerVariable( smSysScript), kTextLanguageDontCare, GetScriptManagerVariable( smRegionCode), NULL, &systemEncoding);
CFStringRef path = CFStringCreateWithPascalString(NULL, fullpath, systemEncoding); url = CFURLCreateWithFileSystemPath(kCFAllocatorSystemDefault, path, kCFURLHFSPathStyle, false);
CFRelease(path);
Hope this helps.
Bryan __ ____ ____ ____ ____ ____ ____ ____ ____ ____ mac-games-dev mailing list | mac-games-dev@(protected) Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/mac -games-dev Do not post admin requests to the list. They will be ignored.
Earn $52 per hosting referral at Lunarpages.
|
|
 |