Re: can't run app from applications folder -- permissions problem?
Re: can't run app from applications folder -- permissions problem?
- Subject: Re: can't run app from applications folder -- permissions problem?
- From: Paul Lynch <email@hidden>
- Date: Tue, 18 Apr 2006 10:46:55 +0100
On 18 Apr 2006, at 00:28, Ben Dougall wrote:
On Tuesday, April 18, 2006, at 12:04 am, Lawrence Sanbourne wrote:
Could this be a problem with quoting? I'm wondering whether the
bundle's resource path needs to be quoted within the string:
system( [[NSString stringWithFormat:@"\"%@/CpMac\" -p \"%@\" \"%@
\"", [[NSBundle
mainBundle] resourcePath], origFile, backupTmpFile] cString] );
Note that in this case, if the path contains double quotes or new
lines, you're in trouble. You probably want to take each of the path
strings and run a method on them (maybe in a category on NSString)
that escapes special characters as needed.
yes, that was it -- thanks. what makes me really stupid was i knew
i hadn't dealt with the possibility of spaces, wrote a message in
the About window "warning, spaces in paths probably will cause
problems" (couldn't be bothered to think how to deal with them and
it really isn't a proper app), then later dropped my app in a
folder in the applications folder that starts with a space
character and resorted to asking on here what the problem was.
For future reference, if you are going to be passing arguments to
some equivalent of system(), you would be better off using execve()
(http://developer.apple.com/documentation/Darwin/Reference/ManPages/
man2/execve.2.html), which handles quoting of arguments for you. Or
even NSTask, which takes a few more lines of code to set up, but does
more or less the same thing.
Paul
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden