Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Fri Sep 21, 2018 6:27 am
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: F.Name assignment under sandboxing
PostPosted: Tue Dec 18, 2012 8:05 am 
Offline

Joined: Tue Dec 18, 2012 7:29 am
Posts: 5
Hello all, can anyone shed any light on this sandboxing related issue:

I have an app which renames files. It has worked fine and been sold for a couple of years. In an attempt to get it ready for the Mac App Store I have made a Cocoa build which works fine until sandboxed.

The user adds a file to a listbox via an open file dialog. I am using OpenDialog and with the entitlement for read (or read/write) access to user selected files (otherwise it does not appear, and causes a delay in the app, no visible crash or error. Nothing happens).

The problem comes when renaming. For example, the user selects a file from the Music folder. The app uses F.Name = new name to rename the folderitem, but generates an OS error -5000, which I can't locate the meaning of. This error does not happen when not sandboxed.

I can 'fix' the error by adding read/write entitlements for the Music folder but the App Store won't accept it claiming my app shouldn't need the entitlements. I understand their point, but the fact is it does need the entitlements to work properly. They also claim I should not be accessing the music folder (or Movies etc), but I've told them such a move would render the app useless if people want to rename files in those folders.

I have tried NSOpenPanel, and have also tried using security scoped bookmarks, they make no difference.

I'm using the lastest Xcode + tools, RB 2012 r2, latest public OS X.


Top
 Profile  
Reply with quote  
 Post subject: Re: F.Name assignment under sandboxing
PostPosted: Tue Dec 18, 2012 8:18 am 
Offline
User avatar

Joined: Wed May 10, 2006 2:42 pm
Posts: 2985
Location: Germany
-5000 is simply a permission error.

Greetings
Christian

_________________
See you in Orlando, Florida for Real World 2013
More details and registration here:
http://www.realsoftware.com/community/realworld.php


Top
 Profile  
Reply with quote  
 Post subject: Re: F.Name assignment under sandboxing
PostPosted: Sun Dec 23, 2012 6:17 am 
Offline

Joined: Tue Dec 18, 2012 7:29 am
Posts: 5
When the cocoa app is sandboxed, and the user selects a file to rename from an open dialog, for example from the music folder, I assume the app then has read/write access to that file (as I have added the read/write access to user selected files entitlement, no others).

So let's say F (folderitem) is returned by the open dialog, trying to rename the file (F.Name = newname) fails with permissions error -5000 unless I add the music folder read/write entitlement in which case the file is renamed. But I can't do that because apple keep rejecting the app saying I shouldn't be using it. Which I understand, as the entitlement 'read/write access to user selected files' should be enough.

I tried the same approach using Delphi/Firemonkey on Windows, the resulting Mac OSX app would also fail (unless the music folder entitlement was added).

Out of curiosity I also tried using security scoped bookmarks to reference 'F' but to no avail.

I've checked the permissions on these files, and they're fine (the renaming works when not sandboxed anyway).
I've removed and reinstalled my OS, my certificates, got all the updated xCode tools.
I've tried the app on a couple of other iMac's too, and used other files from other folders.


Top
 Profile  
Reply with quote  
 Post subject: Re: F.Name assignment under sandboxing
PostPosted: Sun Dec 23, 2012 7:18 am 
Offline
User avatar

Joined: Fri Sep 30, 2005 11:00 am
Posts: 583
Location: Beautiful Taiwan
It simply isn't allowed. The only around it is get the user to allow the application access to the parent folder of the file that you are trying to change, and the only way I know how to do that is to display the select folder dialog.

_________________
Sam Rowlands
rMBP 15" @ 10.8 & '08 MBA 13" @ 10.6 + 10.7, RB2012
http://www.ohanaware.com/
AppWrapper - Prepare Apps for Mac App Store & OS X 10.8 - http://www.ohanaware.com/appwrapper/


Top
 Profile  
Reply with quote  
 Post subject: Re: F.Name assignment under sandboxing
PostPosted: Sun Dec 23, 2012 11:18 am 
Offline

Joined: Tue Dec 18, 2012 7:29 am
Posts: 5
That's pointed me in the right direction, thank you. Been trying to get my head around it for a few days. I just tested what you said and the file renames.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group