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 4 of 13 Topic 1132 of 1217
Post > Topic >>

Re: Getting a programs cannonical path

by "Aaron Gray" <ang.usenet@[EMAIL PROTECTED] > Apr 16, 2008 at 11:03 PM

"BruceMcF" <agila61@[EMAIL PROTECTED]
> wrote in message 
news:03b6d6f6-f06c-4e53-bd09-ec1af3ed7d1f@[EMAIL PROTECTED]
> On Apr 15, 9:19 pm, "Aaron Gray" <ang.use...@[EMAIL PROTECTED]
> wrote:
>> Ah, is there a function that searches the path for an executable and 
>> returns
>> its path ?
>
> Not a C Standard Library function ... that's outside the scope of the
> standard. As I understand it, this is something that Unixen and
> Windows handle differently. You may require a wrapper routine and an
> OS specific definition of that wrapper routine to extract the
> information.
>
> This is, it turns out, a comp.lang.c FAQ:
>
> http://www.faqs.org/faqs/C-faq/abridged/
> QUOTE
> 19.31: How can my program discover the complete pathname to the
> executable from which it was invoked?
>
> A: argv[0] may contain all or part of the pathname.  You may be
> able to duplicate the command language interpreter's search path
> logic to locate the executable.
> UNQUOTE
>
> In a system where argv[0] always contains the absolute pathname, the
> wrapper would just parse argv[0].
>
> In a system where argv[0] contains a filespec that might have been
> used in combination with the path to find the file, then first check
> if the argv[0] has an absolute path, and if not, try passing that
> filespec to the path searching function. There normally will be a path
> searching function in dir.h for, say, a Windows system, which can be
> pressed into service.
>
> ... argv[0] holding the absolute pathname and filename is, of course,
> more secure, but the MS-DOS legacy includes a lot of stuff that is a
> bit slapdash.

Great, what an oversite :(

Anyone got any code for this ?

Thanks,

Aaron
 




 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 0:25:55 CDT 2008.