为了确定文件的大小,我一直使用:
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 沙箱下的符号链接指向的文件的大小?