我正在写一小段代码,在其中我应该检测NSURL包含符号链接(即,还应检测除最后一个之外的符号文件组件)。 为此,我使用-URLByResolvingSymlinksInPath返回的NSURL来对抗NSURL本身。 问题是这个方法似乎以小写形式返回所有符号链接。 有没有其他方法可以解决这个问题?
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?
最满意答案
您可以手动遍历符号链接:
使用-[NSFileManager attributesOfItemAtPath:error:]检测符号链接,并在密钥NSFileType搜索NSFileTypeSymbolicLink值。
使用-[NSFileManager destinationOfSymbolicLinkAtPath:error:]获取目标路径并附加它们。
对每个路径组件重复此操作。
Either I really did something wrong or this bug was fixed with the latest Mountain Lion update. Now all symlinks are correctly resolved.
更多推荐
发布评论