Determining the size of the file specified by a symbolic link in the OS X sandbox

To determine the size of a file, I've always used:

NSDictionary *fileAttributes = [[NSFileManager defaultManager] attributesOfItemAtPath:path error:nil];
unsigned long long size = [fileAttributes fileSize];

      

However, the method attributesOfItemAtPath:error:

does not traverse symbolic links. Apple suggests:

If the element on the path is a symbolic link, that is, the value of the key NSFileType

in the attribute dictionary NSFileTypeSymbolicLink

- you can use the method destinationOfSymbolicLinkAtPath:error:

to get the path to the specified element by reference.

It would be great if the sandbox doesn't prevent me from accessing the specified file:

deny file-read-xattr /path/to/the/original/file

So my question is, how can I get the size of the file pointed to by a symlink in the OS X sandbox?

+3


source to share


1 answer


This seems to be a bug. If the user has deliberately dragged the symbolic link to the application, this is a clear statement of the user's intent and you expect to access the symbolic link and target. In fact, I can access the original file and read its contents, but not its attributes. So I filed bug # 13143810.



EDIT: My bug report was closed as duplicate # 12991152, which is actually "open".

+3


source







All Articles