I'm writing a little piece of code in which I should detect if an NSURL
contains a symbolic link (i.e., symbolic file components other than the last one should also be detected). To do this, I confront the NSURL
itself with the NSURL
returned by -URLByResolvingSymlinksInPath
. The problem is that this method seems to return all symbolic links in lowercase. Is there another way to solve this problem?
Asked
Active
Viewed 2,071 times
1
![](../../users/profiles/28768.webp)
Mike Abdullah
- 14,782
- 2
- 47
- 73
![](../../users/profiles/656488.webp)
Nickkk
- 1,891
- 1
- 20
- 31
-
What's the problem with it returning resolved symlinks in lowercase? – Mike Abdullah Feb 03 '13 at 23:58
-
1Did you try `-[NSString stringByResolvingSymlinksInPath]`? Does it have the same “bug”? – Tricertops Feb 05 '13 at 12:29
2 Answers
4
You can traverse symlinks manually:
Detect symbolic link using
-[NSFileManager attributesOfItemAtPath:error:]
and in keyNSFileType
search forNSFileTypeSymbolicLink
value.Get destination path using
-[NSFileManager destinationOfSymbolicLinkAtPath:error:]
and append them.
Repeat this for every path component.
![](../../users/profiles/1753141.webp)
Tricertops
- 8,414
- 1
- 37
- 41
-
Thanks, this would have been my choice if I didn't notice the bug was resolved! – Nickkk Feb 07 '13 at 16:36
0
Either I really did something wrong or this bug was fixed with the latest Mountain Lion update. Now all symlinks are correctly resolved.
![](../../users/profiles/656488.webp)
Nickkk
- 1,891
- 1
- 20
- 31