Re: NSTask: auxiliary executable does not see its data file
Re: NSTask: auxiliary executable does not see its data file
- Subject: Re: NSTask: auxiliary executable does not see its data file
- From: Jens Alfke <email@hidden>
- Date: Wed, 01 Aug 2012 22:41:47 -0700
On Jul 30, 2012, at 8:08 AM, Daniel Stein <email@hidden> wrote:
> The tool tries to open the file with an ordinary call to fopen():
> f = fopen("my.data",READ_MODE);
Of course this assumes the current directory is the one containing the my.data file. By default it won't be, because the tool inherits the current directory from the app, and IIRC when an app is launched the CWD is set to the root directory of its bundle.
In general it's not a good idea to depend on the CWD in an app anyway. Why not pass the absolute path of the data file as a command-line argument to the tool from NSTask?
> //[ backEnd setCurrentDirectoryPath: [ path stringByDeletingLastPathComponent ] ];
>
> Of course, I'm concerned about having had to comment out the setCurrentDirectoryPath operation
Um, yeah. But you haven't said why you commented it out. From what I remember about NSTask, that line would have set things up so your existing tool would work.
—Jens
_______________________________________________
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