Search code examples
cocoamacossandboxnsfilemanagerosx-lion

Sandboxing and directory listing


A common task I do consists reading a directory content using NSFileManager:contentsOfDirectoryAtPath but enabling sandboxing in Lion this becomes impossible.

I know user must choose from a NSOpenPanel the directory to make Sandbox happy (or dropping it) but how can I "inform" sandbox that I must read directory from a path previously stored in some configuration file without user interaction?

Currently I've set the following entitlement keys

com.apple.security.files.user-selected.read-write
com.apple.security.documents.user-selected.read-write
com.apple.security.temporary-exception.files.absolute-path.read-write

Solution

  • The sandbox currently doesn't remember what's it allowed to access on the file system between application launches.

    This is tracked at Apple at some high-priority radar but I still suggest that you file your own bug report as well, to raise its awareness even higher within Apple.