discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to obtain GNUstep environment values without openapp or GNUstep.


From: Quentin Mathé
Subject: Re: How to obtain GNUstep environment values without openapp or GNUstep.sh?
Date: Tue, 5 Dec 2006 10:01:45 +0100

Le 5 déc. 06 à 06:26, Richard Frith-Macdonald a écrit :

On 5 Dec 2006, at 02:07, Quentin Mathé wrote:

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?

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.

This is exactly what I was looking for :-) I didn't think to use NSSearchPathForDirectoriesInDomains() in part because I made the wrong assumption it wouldn't work in my case.

Thanks,
Quentin.

--
Quentin Mathé
qmathe@club-internet.fr





reply via email to

[Prev in Thread] Current Thread [Next in Thread]