Article View: comp.sys.amiga.tech
Article #536Re: What is my name?
From: Darren New
Date: Wed, 19 Jul 1989 17:50
Date: Wed, 19 Jul 1989 17:50
27 lines
1718 bytes
1718 bytes
In article <1227@atanasoff.cs.iastate.edu> jwright@atanasoff.cs.iastate.edu.UUCP (Jim Wright) writes:
>Wouldn't this fail if, for example, I had a script file in S: which
>then explicitly called the program and the program was not in a directory
>on the PATH.
Wouldn't argv[0] then contain the full path-name of the program?
You may need to use _main (before the parsing gets done). It must
be doable, since the CLI does it and you have all the information
in the process structure you need. I would think you could do
it as follows:
1) attempt to obtain a lock on argv[0] (or the first string in the
command line, if _main). If that succeeds, use that lock to
generate the full path name.
2) walk down the path, attempting to lock argv[0] from each directory
so found. If I remember, the path in some way hangs off of the
current directory pointer in the process structure. When found,
use that lock to find the full path name.
3) try to loc strcat("C:", argv[0]);
4) If all of these fail, then my algorithm is wrong :-).
Note that you can CD to a file and not just a directory. Thus any
print-current-directory function should be able to give you the
full path of a lock. (Er, from DOS calls, not with the CD command.)
-- Darren
Technical Details
Message-ID:
<20048@louie.udel.EDU>Path:
arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!gatech!udel!newReferences:
<26385@agate.BERKELEY.EDU> <20565@cup.portal.com> <1227@atanasoff.cs.iastate.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!gatech!udel!new From: new@udel.EDU (Darren New) Newsgroups: comp.sys.amiga.tech Subject: Re: What is my name? Message-ID: <20048@louie.udel.EDU> Date: 19 Jul 89 17:50:00 GMT References: <26385@agate.BERKELEY.EDU> <20565@cup.portal.com> <1227@atanasoff.cs.iastate.edu> Sender: usenet@udel.EDU Reply-To: new@udel.EDU (Darren New) Organization: University of Delaware Lines: 27