Quicksand boxed – a tale of woe.
Quicksand boxed – a tale of woe.
- Subject: Quicksand boxed – a tale of woe.
- From: Joel Norvell <email@hidden>
- Date: Thu, 12 Apr 2018 17:03:34 -0700
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 (email@hidden)
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:
This email sent to email@hidden