Renaming a file programmatically in a sandbox fails

Originator:graeter
Number:rdar://12875119 Date Originated:13-Dec-2012 07:09 PM
Status:Open Resolved:
Product:MacOS X Product Version:10.8
Classification:Serious Bug Reproducible:Always
 
SUMMARY

Renaming a file with NSFileManager's -moveItemAtURL:toURL:error: in a sandboxed environment fails.

Even though the documentation of NSFileCoordinator's itemAtURL:willMoveToURL: suggests that renaming a file is possible in a sandboxed environment.

At least renaming files programmatically should be possible. Currently renaming is limited to NSDocument-based applications that either use a saveToURL:-method of NSDocument or that use the 'Rename' menu item of the title bar of the document window.



STEPS TO REPRODUCE

See attached example project:

1. Run the example
2. Select a text file

3. The program should be able to read / save / reread the file

4. The program fails to rename the file



EXPECTED RESULTS:

- The program should be able to rename the file programmatically.



ACTUAL RESULTS:

- The permission is denied by sandboxing.

Comments

Reposted as rdar://12875340

By maxseelemann at Dec. 13, 2012, 6:35 p.m. (reply...)

Sample project


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!