"Aaron Gray" <ang.usenet@[EMAIL PROTECTED]
> wrote in message
news:66l2i4F2kr8faU1@[EMAIL PROTECTED]
> "Aaron Gray" <ang.usenet@[EMAIL PROTECTED]
> wrote in message
> news:66l1sbF2lab4iU1@[EMAIL PROTECTED]
> > Hi,
> >
> > I was under the missaprehention that argv[0] would be the cannonic
path
of
> > the running C program, but it does not appear to be so.
> >
> > How do I get the cannonical path of the running program in a cross
> > platform way ?
If there is a relative path on argv[0], you might chdir() to the relative
path and getcwd() to get the full path... (?)
DOS has a number of "get canonical path" functions... I'd assume other
OSes
have their own versions.
> Ah, is there a function that searches the path for an executable and
returns
> its path ?
You might be able to find some "walk directory" or "tree walk" or "ftw"
functions already written for various OSes. If you write a (or use a
pre-written) "walk directory" function, try to find one that uses POSIX's
opendir,readdir,closedir, etc. directory functions. The functions are
widely available for different OSes. For *nix, Doug Gwyn wrote libndir or
libndir-posix. I've also seen the set of functions available for Windows
and DOS.
LSBC compliant Linux should have the ftw ("file tree walk") functions.
Rod Pemberton


|