www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1994/12/16/07:53:35

To: djgpp AT sun DOT soe DOT clarkson DOT edu
Path: mantis!not-for-mail
From: olly AT mantis DOT co DOT uk (Olly Betts)
Newsgroups: mail.djgpp
Subject: Re: Getting a path in argv[0]
Date: 16 Dec 1994 11:53:56 -0000
Organization: Mantis Consultants Ltd, Cambridge, UK
Lines: 39

In article <3cqdvu$76d AT gap DOT cco DOT caltech DOT edu>,
Charles Fu <ccwf AT russel DOT klab DOT caltech DOT edu> wrote:
>In article <3bn4kb$13h AT sunforest DOT mantis DOT co DOT uk>,
>Olly Betts <olly AT mantis DOT co DOT uk> wrote:
>>>At anyrate, the portable solution is to manully check the path().
>>>
>>>I remember when I played around with the DLD package, it had a
>>>routine for checking the path to do just this.  I just had to
>>>modify it slightly to use ; as path separators rather than ;.
>>>Check out prep.ai.mit.edu in pub/gnu/dld323.tar.gz (or some
>>>similar name).
>>
>>I'll take a look at that.  It'd be useful for the UNIX version not
>>to need an environmental variable set.
>
>It's a little unclear what you environment variable you are referring to.

The problem is to find some support files which live in the same
directory as the executable.  Ideally I'd like to do this by looking at
argv[0] and reading off the path.  An obvious alternative is to look for
an environmental variable (eg. FOOPATH) and look in the directory it
points to.  This is best avoided under DOS, as you need to explain to
the user how to modify their autoexec.bat, and environment space is at
something of a premium.  UNIX users tend to be somewhat more savvy, and
they'll have to work out how to compile the code anyhow.

>This
>is off-topic, but if you are looking for a portable foolproof way to recover
>the executable's path from argv[0] or anything else under UNIX, it doesn't
>exist.  (You can make educated but possibly incorrect guesses, however.  Some
>flavors of UNIX do allow getting this information, but such features are not
>widespread and are not poartable.)  This is well covered, I believe, in the
>comp.unix.shell and programmer FAQs.

Cheers.  I'll take a look.

Olly
-- 
suckSqueezeBANGblowsuckSqueezeBANGblowsuckSqueezeBANGblowsuckSqueezeBANGblow

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019