sandboxd deny file-write-create
sandboxd deny file-write-create
- Subject: sandboxd deny file-write-create
- From: Pax <email@hidden>
- Date: Sun, 24 Nov 2013 17:04:57 +0000
Okay, so I think I know what the problem is here - the problem is that I prompt the user for a filename, and then I modify the filename before using it. I suspect that sandboxd looks dimly on what I've done, and considers me to be riding roughshod over the users wishes! In fact I'm not, but there's no way for sandboxd to know this!
Here's the problem. I'm writing out (potentially) very large files. It might be that the user doesn't want one huge xml file - instead they might want a bunch of smaller xml files. Therefore I prompt the user for a filename (which I use as a base) and then I append a number. So, for example, if the user specifies that they'd like the file to be called file.xml, I modify this to:
file 1.xml
file 2.xml
file 3.xml and so forth.
I do this with the following code:
else if (([ftype isEqualToString:@"xml"])&&merge&&(mergeCount>0)&&([outputFile count]>0))
{
newURL = [NSURL URLWithString:[[NSString stringWithFormat:@"%@ %d.xml",[saveFilePath lastPathComponent],mfCount]
stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]
relativeToURL:saveFilePath];
NSMutableDictionary* mergedOutputFile = [[NSMutableDictionary alloc]init];
[mergedOutputFile setObject:[settings objectForKey:@"ElementsArray"]
forKey:@"FormatDefinition"];
[mergedOutputFile setObject:outputFile
forKey:@"Content"];
success = [mergedOutputFile writeToURL:newURL atomically:YES];
if (!success) NSLog(@"Failed to write output file");
}
This code works file until I turn sandboxing on - and then it fails. The following code works fine in the sandbox, but without the benefit of appended numerals - making it impossible for me to split the file into chunks.
else if (([ftype isEqualToString:@"xml"])&&merge&&(mergeCount>0)&&([outputFile count]>0))
{
newURL = [NSURL URLWithString:[[NSString stringWithFormat:@"%@",[saveFilePath lastPathComponent]]
stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]
relativeToURL:saveFilePath];
NSMutableDictionary* mergedOutputFile = [[NSMutableDictionary alloc]init];
[mergedOutputFile setObject:[settings objectForKey:@"ElementsArray"]
forKey:@"FormatDefinition"];
[mergedOutputFile setObject:outputFile
forKey:@"Content"];
success = [mergedOutputFile writeToURL:newURL atomically:YES];
if (!success) NSLog(@"Failed to write output file");
}
Does anyone have any cunning plan for how I might achieve the functionality that I need without breaking the sandbox?
_______________________________________________
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