Thanks for reply!
Crrently in code used NavGetFile (it's look like very old dialog
function...??)
>From FSSpec I get the only full path, but not file name:
FSRef fsRef;
CFURLRef URLRef;
OSErr oserr;
CFStringRef StringRef;
oserr = FSpMakeFSRef( &documentFSSpec, &fsRef );
URLRef = CFURLCreateFromFSRef(kCFAllocatorDefault, &fsRef);
StringRef = CFURLCopyFileSystemPath( URLRef, kCFURLPOSIXPathStyle
);
CFStringGetCString( StringRef, (char*)&theFile->FileName,
sizeof(theFile->FileName), kCFStringEncodingMacHFS );
Ok, I'll learn this issue later...
Thanks!
> Thanks for reply!
>
> Crrently in code used NavGetFile (it's look like very old dialog
> function...??)
>
> >From FSSpec I get the only full path, but not file name:
> FSRef fsRef;
> CFURLRef URLRef;
> OSErr oserr;
> CFStringRef StringRef;
> oserr = FSpMakeFSRef( &documentFSSpec, &fsRef );
> URLRef = CFURLCreateFromFSRef(kCFAllocatorDefault, &fsRef);
> StringRef = CFURLCopyFileSystemPath( URLRef, kCFURLPOSIXPathStyle
> );
> CFStringGetCString( StringRef, (char*)&theFile->FileName,
> sizeof(theFile->FileName), kCFStringEncodingMacHFS );
>
> Ok, I'll learn this issue later...
You should use the newer Nav Serv APIs. Avoid any API that uses FSSpecs.
> Crrently in code used NavGetFile (it's look like very old dialog
> function...??)
No, it's not VERY old. It's merely passe. StandardGetFile is very old.
SFGetFile is ancient.
>
> >From FSSpec I get the only full path, but not file name:
> FSRef fsRef;
> CFURLRef URLRef;
> OSErr oserr;
> CFStringRef StringRef;
> oserr = FSpMakeFSRef( &documentFSSpec, &fsRef );
> URLRef = CFURLCreateFromFSRef(kCFAllocatorDefault, &fsRef);
> StringRef = CFURLCopyFileSystemPath( URLRef, kCFURLPOSIXPathStyle
> );
Another thing you can do with a CFURLRef is extract the components of
its path as strings. CFURLCopyLastPathComponent() is the one you want
for just the leaf name.
Thanks for reply!
OS: 10.3.9+
There in code used only NavGetFile function.
I've used some code:
FSRef fsRef;
CFURLRef URLRef;
OSErr oserr;
CFStringRef StringRef;
oserr = FSpMakeFSRef( &documentFSSpec, &fsRef );
URLRef = CFURLCreateFromFSRef(kCFAllocatorDefault, &fsRef);
StringRef = CFURLCopyFileSystemPath( URLRef, kCFURLPOSIXPathStyle
);
CFStringGetCString( StringRef, (char*)&theFile->FileName,
sizeof(theFile->FileName), kCFStringEncodingMacHFS );
But I got full file name, is the way get only filename? Of course I
can parse it for "//".
Mach thanks!