【发布时间】:2013-01-14 03:25:09
【问题描述】:
为了确定文件的大小,我一直使用:
NSDictionary *fileAttributes = [[NSFileManager defaultManager] attributesOfItemAtPath:path error:nil];
unsigned long long size = [fileAttributes fileSize];
但是,方法attributesOfItemAtPath:error: 不遍历符号链接。苹果建议:
如果路径处的项目是符号链接——即属性字典中
NSFileType键的值是NSFileTypeSymbolicLink——你可以使用destinationOfSymbolicLinkAtPath:error:方法来检索指向的项目的路径通过链接。
如果沙盒不阻止我访问指定的文件,那就太好了:
拒绝文件读取 xattr
/path/to/the/original/file
那么,我的问题是:如何获取 OS X 沙箱下符号链接指向的文件的大小?
【问题讨论】:
-
符号链接指向的文件是否在您的沙箱之外?
标签: macos cocoa sandbox nsfilemanager