On 5 Dec 2006, at 02:07, Quentin Mathé wrote:
Le 4 déc. 06 à 15:46, Nicola Pero a écrit :
What do you mean by 'enviromental' variables ? Which variables
exactly
do you need and why ? ;-)
GNUSTEP_SYSTEM_ROOT, LD_LIBRARY_PATH etc.
Just to be able to launch tool like gpbs with NSTask and without
modifying PATH or using opentool. I would like to do the same for
an application like Gorm (I mean without using openapp). If I know
GNUSTEP_SYSTEM_ROOT, I can find them easily because tools or
applications I plan to launch won't be moved once installed.
However GNUSTEP_SYSTEM_ROOT may change depending on the user or the
machine, so I either need a way to know its value or an API that
allows to search for tool and application path in standard
locations like GNUSTEP_SYSTEM_ROOT and GNUSTEP_LOCAL_ROOT.
My daemonizer process is launched with a copy of libgnustep-base
put in /usr/lib because if I try to launch it without such copy, it
complains about libgnustep-base not available (not surprisingly
since it is installed by default in /System/Library/Libraries on my
machine).
So I was supposing that environment variables I just mention
weren't set for this process, but perhaps I make a wrong assumption?
To locate the application binaries, you should use gnustep-base's
NSBundle
methods to locate stuff in the various domains.
Which methods? I don't understand how I can find an application
binary like Gorm with NSBundle (from another process). May be with
NSWorkspace though by running make_services first?
But this wouldn't solve the problem for a tool like gpbs. I don't
think make_services cache information about installed tools.
One you have found the application binary, you just execute it.
Give to
the application binary the same environment that your process is
using,
and it will work. :-)
If the environment is properly set, it should work :-)
1. When you install GNUstep, you should add the paths of the
directories containing GNUstep libraries to /etc/ld.so.conf and run
the ldconfig program to update the systems cache of library paths.
Putting libgnustep-base in /usr/lib has a similar effect, but you
need to remember to do that for every library you might want to
use ... so adding directories to /etc/ld.so.conf is less error prone
as it means you are less likely to miss a library.
2. Use the NSSearchPathForDirectoriesInDomains() function to get a
list (NSArray) of the directories that your tool may be in.
3. For each path in the list, call [NSString-
stringByAppendingPathComponent:] to add the program name to the
directory, call [NSFileManager-fileExistsAtPath:isDirectory:] to see
if the named program exists and if it is a directory.
4a. If the path you found is a directory (an app) ... use the
NSBundle API to access the directory bundle and determine the path to
the executable in the bundle, then pass that to NSTask to launch.
4b. If the path is not a directory, just use it as the launch path
for NSTask directly.
_______________________________________________
Discuss-gnustep mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/discuss-gnustep