Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Languages Misc > Re: Getting a p...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 8 of 13 Topic 1132 of 1217
Post > Topic >>

Re: Getting a programs cannonical path

by "Rod Pemberton" <do_not_have@[EMAIL PROTECTED] > Apr 16, 2008 at 07:52 PM

"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
 




 13 Posts in Topic:
OT: Getting a programs cannonical path
"Aaron Gray" &l  2008-04-16 02:08:19 
Re: Getting a programs cannonical path
"Aaron Gray" &l  2008-04-16 02:19:53 
Re: Getting a programs cannonical path
BruceMcF <agila61@[EMA  2008-04-16 07:27:12 
Re: Getting a programs cannonical path
"Aaron Gray" &l  2008-04-16 23:03:50 
Re: Getting a programs cannonical path
Marco van de Voort <ma  2008-04-17 14:59:54 
Re: Getting a programs cannonical path
Marco van de Voort <ma  2008-04-21 16:02:20 
Re: Getting a programs cannonical path
BruceMcF <agila61@[EMA  2008-04-16 16:46:29 
Re: Getting a programs cannonical path
"Rod Pemberton"  2008-04-16 19:52:37 
Re: Getting a programs cannonical path
"Aaron Gray" &l  2008-04-17 01:22:40 
Re: Getting a programs cannonical path
"Rod Pemberton"  2008-04-17 02:59:45 
Re: Getting a programs cannonical path
"Aaron Gray" &l  2008-04-21 16:18:27 
Re: Getting a programs cannonical path
"Rod Pemberton"  2008-04-21 15:57:46 
Re: Getting a programs cannonical path
"Aaron Gray" &l  2008-04-22 11:52:45 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Jul 25 23:47:33 CDT 2008.