解析NSURL中的所有符号链接(Resolving all symbolic links in NSURL)

系统教程 行业动态 更新时间:2024-06-14 16:59:47
解析NSURL中的所有符号链接(Resolving all symbolic links in NSURL)

我正在写一小段代码,在其中我应该检测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.

更多推荐

本文发布于:2023-04-17 08:54:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/dzcp/7948f5d08d0e09a4e71c71f44a624f94.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:符号   链接   NSURL   links   symbolic

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!