Re: Sandbox, security bookmarks and trash
Re: Sandbox, security bookmarks and trash
- Subject: Re: Sandbox, security bookmarks and trash
- From: Mike Abdullah <email@hidden>
- Date: Mon, 29 Oct 2012 11:55:25 +0000
On 27 Oct 2012, at 12:07, Simone Tellini <email@hidden> wrote:
> Hello,
>
> I need to handle an "export" function in a document-based application.
>
> When the user creates the document, he can also choose a couple of path where to save different exported results (e.g. "~/Documents/exporteddata.xml"). The document contains security bookmarks that point to those files, so that when the user reopens the document, he can simply hit "export" to generated them again, overwriting the previous data.
>
> Problem is, if the user moves one of those files to the trash, the next time the application resolves the security bookmark it will point to the deleted file (ie. something like ".../.Trash/..."). I'd rather like the application to keep on re-creating the file at the path the user has chosen in the first place (ie. "~/Documents/exporteddata.xml").
>
> Is it possible? Or how do you handle this scenario in an user-friendly way?
You're up against the design of bookmarks here. By default they resolve to the original URL, but if that no longer exists, search the disk by file ID. So in your case, the file in the trash is being found. When creating the bookmark, there is an option to resolve in the opposite order, but that won't help you here.
There's also an option to create a "minimal" bookmark. The docs don't say what's different about that. Have you tried it at all?
In a non-sandboxed app, the proper solution would be to instead create a bookmark to the folder for exporting to (e.g. ~/Documents/). You could add in a custom property to the bookmark of the filename to export to.
The trick in a sandboxed app is getting write permission to that folder. NSSavePanel only gives you write access to the user-entered filename I believe, not the whole folder. Perhaps you could instead throw up an open panel, asking which folder to export to? Of course, this would have to be an app-scoped bookmark, since the target is a directory. Not sure if that's a problem for your app.
Most importantly, file a radar for your needs. Maybe open a DTS incident too.
_______________________________________________
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