When you're application is sandboxed, it has access to documents within the sandbox -- period.
If you display an open dialog, you can ask the user for a file/folder (and by inference, permission to access that file/folder). There used to be a way to denote a specific file/files to be able to access, but I don't recall if that's been turned off or not. -- Glenn L. Austin, Computer Wizard, AustinSoft.com > On Apr 12, 2018, at 5:03 PM, Joel Norvell <framewor...@fastmail.com> wrote: > > Hi Cocoa-dev People, > > I have a sandboxing question, below. I'm wondering if it's even possible to > do what I tried to do, and if so, how? > > Thanks, > Joel Norvell > > > I'm trying to iterate directories in a sandboxed app in order to find a file > with a specific extension. > > I believe I have all the entitlements that are available that might help: > > App Sandbox > com.apple.security.files.downloads.read-write > com.apple.security.files.user-selected.read-write > com.apple.security.print > com.apple.security.temporary-exception.files.home-relative-path.read-write > com.apple.security.temporary-exception.files.absolute-path.read-write > > I need to be able to find a file, by name, that could either be on the > Desktop or in the (real) Documents folder. I don't even get close. I get a > filecoordinationd when I try to iterate either of them (code below). I am > able to find a file, by name, in the Downloads folder, though. > > Has anyone been able to do this with the Desktop folder or the (real) > Documents folder? (When I used NSDocumentDirectory it looked in the Documents > folder attached to my container. I could find things that were in that. But > it wasn't the same as the Documents folder that the user sees.) > > If I turn off Sandboxing I have no problem iterating Desktop or Documents. > > This is the code I used to test iterating in three NSSearchPathDirectories: > NSDocumentDirectory, NSDesktopDirectory, and NSDownloadsDirectory. > > NSFileManager* fm = [NSFileManager new]; > NSError* err = nil; > NSURL* rootDirURL = > [fm URLForDirectory:NSDesktopDirectory > inDomain:NSUserDomainMask appropriateForURL:nil > create:NO error:&err]; > // error-checking omitted > > NSURL * theFormsFolderURL = [self formsFolderURL:rootDirURL]; > > - (NSURL *) formsFolderURL:(NSURL *)rootDirURL > { > NSFileManager * fm = [NSFileManager defaultManager]; > > NSDirectoryEnumerator* dir = [fm enumeratorAtURL:rootDirURL > includingPropertiesForKeys:nil > options:0 errorHandler:nil]; > > for (NSURL* f in dir) > { > if ([[f pathExtension] isEqualToString:@"pdq"]) > { > NSLog(@"%@", [f lastPathComponent]); > } > } > > return nil; // Dummy nil > } > > BTW, this was the value that gave me a filecoordinationd for Desktop: > rootDirURL NSURL * > @"file:///Users/joely/Library/Containers/biz.pdqforms.pdqforms/Data/Desktop/" > _______________________________________________ > > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) > > Please do not post admin requests or moderator comments to the list. > Contact the moderators at cocoa-dev-admins(at)lists.apple.com > > Help/Unsubscribe/Update your Subscription: > https://lists.apple.com/mailman/options/cocoa-dev/glenn%40austinsoft.com > > This email sent to gl...@austinsoft.com _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com