runtime execution path for NSTask
runtime execution path for NSTask
- Subject: runtime execution path for NSTask
- From: Chris Heimark <email@hidden>
- Date: Fri, 13 Jul 2007 15:04:20 -0400
Hi:
I'm using an NSTask object to run a command line program. Everything
works as expected and I am just buttoning things up ... one of which
is a hard coding of a path to my executable for NSTask. If I let
Xcode execute either debug or release versions of Cocoa app, it finds
my executable in same directory no problem. When I double-click Cocoa
app out of finder, execution path is marked as '/' which I have
discovered has the meaning of 'relative path' in this context. If a
command line program and Cocoa app are in same directory, how do I
tell NSTask that executable is in same path (not relative) as the
launching Cocoa app?
I have searched docs high and low and find only vague reference to
relative path using NSFileManager methods.
"Puzzled in Malvern, PA, USA"
Chris
if ([[[NSFileManager defaultManager] currentDirectoryPath]
isEqualToString:@"/"])
// this does not work when executing release or debug code from finder
xpath = @"read-data-usb";
else
// this works no problem when Xcode runs either release or debug code
xpath = [[[NSFileManager defaultManager] currentDirectoryPath]
stringByAppendingString:@"/read-data-usb"];
_______________________________________________
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