I've noticed that FSPathMakeRef()
and FSRefMakePath()
are now deprecated in OS X 10.8.
I have some code that uses them to find the canonical case for a path, e.g. if passed "/USeRs" it will return "/Users".
Why have these and other related functions been deprecated, and what non-deprecated API should be used now instead to provide equivalent functionality?
Use NSURL
to store both ordinary paths and file reference paths.
From the File Manager documentation (Appendix A: Deprecated File Manager Functions):
FSMakeFSRefUnicode
Constructs an FSRef for a file or directory, given a parent directory and a Unicode name. (Deprecated in OS X v10.8. Use NSURL or CFURL APIs instead. To track the behavior of file-system items by ID, create file reference URLs using fileReferenceURL or CFURLCreateFileReferenceURL.)
From what I can tell, Apple chose to deprecate the FSRef
type entirely, favouring file reference URLs (which look like file:///.file/id=6571367.39068/
) instead.
If you want to canonicalize a string path, you can do the following using non-deprecated APIs:
NSString *canonicalPath = [[[NSURL fileURLWithPath:@"/USeRs"] fileReferenceURL] path];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With