Re: adding an executable as a resource
Re: adding an executable as a resource
- Subject: Re: adding an executable as a resource
- From: "Sean McBride" <email@hidden>
- Date: Fri, 9 Dec 2005 12:44:29 -0500
- Organization: Rogue Research
On 2005-12-09 15:36, Markus Hitter said:
>
Am 09.12.2005 um 14:08 schrieb Ron Fleckner:
>
>
> I'm a bit worried because it was so easy to do.
>
>
Welcome to Cocoa/Obj-C.
>
>
> There are only eleven lines of code inside the action method!
>
>
You could get away with 3 lines (roughly):
Lots of bugs in just 3 lines. :)
>
char * command[MAX_PATH * 2];
>
sprintf(command, "%s/Resources/lame %s", [[[NSBundle mainBundle]
>
bundlePath] UTF8String], filename);
>
system(command);
Are you sure that will work with all pathnames? One should use -
fileSystemRepresentation not -UTF8String when building paths. But since
you're trying to get something in .app/Resources/ it would be better to
call NSBundle's -resourcePath, or even better -pathForResource:ofType:.
Also, what encoding does sprintf() expect? Is it the same as the file
system encoding, I don't know... better to use NSString's
stringByAppendingPathComponent: instead. Also hardcoding an array size
of MAX_PATH*2, while probably safe, is lame.
And to the OP, you should be aware that calls like system() are very
dangerous, see:
<
http://lists.apple.com/archives/carbon-dev/2005/Jun/msg00046.html>
Welcome to Cocoa. So easy. :)
--
____________________________________________________________
Sean McBride, B. Eng email@hidden
Rogue Research www.rogue-research.com
Mac Software Developer Montréal, Québec, Canada
_______________________________________________
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