How to get NSSt开发者_开发百科ring (Unix style path) from FSSpec
Regards, Dhana.
- Create an FSRef for the FSSpec.
- Create a CFURL for the FSRef.
- Copy or get an NSString of the URL's file-system path, using either the
CFURLCopyFileSystemPath
function or the-[NSURL path]
method.
Don't forget to release the CFURL, since you Created it. The same goes for the path, if you Copied it.
I think below code will work fine..
If wrong please modify..
char * UnixPathFromFSSpec(FSSpec *sfile)
{
char unixPath[2048];
unixPath[0] = '\0';
FSRef ref;
if(FSpMakeFSRef(sfile, &ref) == noErr )
{
FSRefMakePath(&ref, unixPath, sizeof(unixPath));
}
return unixPath;
}
精彩评论