开发者

How to get NSString (Unix style path) from FSSpec

开发者 https://www.devze.com 2022-12-19 10:35 出处:网络
How to get NSSt开发者_开发百科ring (Unix style path) from FSSpec Regards, Dhana. Create an FSRef for the FSSpec.

How to get NSSt开发者_开发百科ring (Unix style path) from FSSpec

Regards, Dhana.


  1. Create an FSRef for the FSSpec.
  2. Create a CFURL for the FSRef.
  3. 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;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消