473,388 Members | 1,298 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

Re: Getting a programs cannonical path

On Apr 16, 6:03 pm, "Aaron Gray" <ang.use...@gmail.comwrote:
"BruceMcF" <agil...@netscape.netwrote in message
news:03**********************************@b64g2000 hsa.googlegroups.com...
On Apr 15, 9:19 pm, "Aaron Gray" <ang.use...@gmail.comwrote:
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 ?
I don't ... last time I was doing full on C programming, in the
mid-90's, it was all in PowerC from Mix, in DOS, for my own use, so I
was working in my own filesystem I had specified.

Maybe someone on comp.lang.c does? Follow-up reset to comp.lang.c
Jun 27 '08 #1
0 1092

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Darren Dale | last post by:
Is there a place to put python programs so I dont have to refer to the absolute path everytime I want to call them? For example: if I am in /home/me and want to execute: python...
8
by: Rod | last post by:
I have been working with ASP.NET 1.1 for quite a while now. For some reason, opening some ASP.NET applications we wrote is producing the following error message: "The Web server reported...
8
by: bryan | last post by:
Is there any way I can get the application path (the one returned by Request.ApplicationPath) in the Application_Start method in Global.asax? Request is not valid there. On a related note, is there...
18
by: W. Watson | last post by:
What do I download to use Python with MX XP Pro on an ASUS 4 year old motherboard? I would guess a good book source for starters would be the O'Reilly book. Wayne T. Watson (Watson Adventures,...
3
by: irfan.mohammed | last post by:
Dear All, I am working on php with html form input type file.i want to get the fullpath of my file which i have selected from my computer. example :C:\programs\..... can anyone help me, ...
0
by: buntyindia | last post by:
Hi, I have a very strange problem with my application. I have developed it using Struts. I have a TextBox With Some fixed value in it and on Submit iam passing it to another page. <html:form...
3
blazedaces
by: blazedaces | last post by:
Hello, it's been a while since I posted on these forums. My issue I think isn't as much in my code as it's in the syntax and structure in references other packages. I'll get straight to it then: ...
185
by: jacob navia | last post by:
Hi We are rewriting the libc for the 64 bit version of lcc-win and we have added a new field in the FILE structure: char *FileName; fopen() will save the file name and an accessor function will...
5
by: Sin Jeong-hun | last post by:
Hello. Speical folders, like Desktop, usually have different display names. For example, in Japanese Windows, it's displayed as "$B%G%9%/%H%C%W(B". I want to get the this displayed name of a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.