Setting permissions for files within an application on non-admin accounts...
Setting permissions for files within an application on non-admin accounts...
- Subject: Setting permissions for files within an application on non-admin accounts...
- From: Keith Blount <email@hidden>
- Date: Wed, 5 Nov 2008 13:03:27 -0800 (PST)
Hi,
I have the feeling this may be a stupid question and that I'm missing the obvious here, but...
My application comes with an interactive tutorial - that is, a tutorial that uses my app's file format so that the user opens it in my app and learns how to use the program by the very process of going through the tutorial, as with many programs.
The best way of distributing this tutorial has always been a problem. My application cannot open read-only files, so it requires the tutorial file (or any other file it opens for that matter) to have the correct permissions for the user to be able to open it. I used to distribute this tutorial as a separate file on the program's installer DMG with instructions in the readme to copy it somewhere locally. However, I soon discovered that many users don't read the readme file (I have no idea why that was a surprise to me given that I never read them myself), so many would try to open the tutorial straight from the DMG and get a message saying that the tutorial couldn't be opened because they didn't have the correct permissions - not a good first impression, obviously.
My solution was this: have the tutorial built into the application itself (that is, part of my Xcode project so that it gets compiled into the Resources folder of the application bundle). When the user selects "Tutorial" from the Help menu, if it is the first time they have used the program, they are prompted with a panel that tells them that because the tutorial is interactive, they should choose a location to save a copy. The app then copies the tutorial from inside the application bundle to the specified path (and saves the specified path in the defaults so that the next time the user selects Help > Tutorial it will open straight up without the prompt, unless it has been deleted).
This works well for most users... Unless they are using a non-admin account. In this case, it seems that the tutorial file inside the app bundle doesn't have the correct file permissions to get copied out of the app bundle at all, so NSFileManager's copyPath:toPath:handler: fails in the attempt.
One solution is for me to use BatChmod on the tutorial file to ensure that the tutorial file and all its contents (my file format is a package format, which complicates things - i.e. all of the package contents also need the correct permissions) have the correct permissions for everyone - read, write, execute. However, I was hoping that there was a more elegant solution in code in case I make an amendment to the tutorial file and forget to BatChmod it before a release at some point in the future.
Or, if there is a better solution to this sort of thing altogether, I'd love to hear it.
Many thanks in advance and all the best,
Keith
_______________________________________________
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