Article View: comp.sys.amiga.tech
Article #517Re: What is my name?
From: Mike (I'll think of something ye...
Date: Tue, 18 Jul 1989 03:10
Date: Tue, 18 Jul 1989 03:10
48 lines
2146 bytes
2146 bytes
<In article <26385@agate.BERKELEY.EDU> mwm@mica.berkeley.edu (Mike (I'll think of something yet) Meyer) writes: <>Before I sit down & write it myself, does anyone have a piece of code <>that will give me a full name for the binary it's running in? Not just <>argv[0], but the name path & file name (not file, but c:file, or <>sys:system/file, or whatever). < <Listing 2.9 in the Programmer's Guide To The Amiga gives you the <path to where the binary is located. You can use argv[0] for the <binary's name. The program is called mybranch.c I must have not made myself clear - you're the second person to make that mistake. The code in listing 2.9 prints the name of the current directory. This is may not be the name of the directory that the running file is from. Consider the following script, with "myname.c" as the program I'm looking for: 1> path Current directory bin:Utilities bin:System bin:S C: 1> cd src:c 1> cc myname.c -o myname 1> myname src:c/myname 1> copy myname ram: 1> ram:myname ram:myname 1> rename ram:myname c: ; Note: no longer a copy in current directory 1> myname c:myname ; Or bin:c/myname, or dh0:c/myname, or etc. 1> rename c:myname c:system 1> myname bin:system/myname ; Or dh0:system/myname, or some such. 1> You see the difference? The code is conceptually simple, but has some non-trivial details (like dealing with "//x/y/myname") to make it work right. <mike -- He was your reason for living Mike Meyer So you once said mwm@berkeley.edu Now your reason for living ucbvax!mwm Has left you half dead mwm@ucbjade.BITNET
Technical Details
Message-ID:
<26406@agate.BERKELEY.EDU>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!bionet!agate!eris.berkeley.edu!mwmReferences:
<26385@agate.BERKELEY.EDU> <7330@ardent.UUCP>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!bionet!agate!eris.berkeley.edu!mwm From: mwm@eris.berkeley.edu (Mike (I'll think of something yet) Meyer) Newsgroups: comp.sys.amiga.tech Subject: Re: What is my name? Message-ID: <26406@agate.BERKELEY.EDU> Date: 18 Jul 89 03:10:29 GMT References: <26385@agate.BERKELEY.EDU> <7330@ardent.UUCP> Sender: usenet@agate.BERKELEY.EDU Reply-To: mwm@eris.berkeley.edu (Mike (I'll think of something yet) Meyer) Organization: Missionaria Phonibalonica Lines: 48