From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,b97aa4480eccc494 X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!news2.google.com!postnews.google.com!j4g2000prf.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: How to get the application path Date: Tue, 24 Jul 2007 07:55:00 -0700 Organization: http://groups.google.com Message-ID: <1185288900.324049.237880@j4g2000prf.googlegroups.com> References: <46a456aa$0$25908$426a34cc@news.free.fr> <1185204459.328520.240930@z24g2000prh.googlegroups.com> NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1185288900 8338 127.0.0.1 (24 Jul 2007 14:55:00 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 24 Jul 2007 14:55:00 +0000 (UTC) In-Reply-To: User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.7.12) Gecko/20050922 Fedora/1.7.12-1.3.1,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: j4g2000prf.googlegroups.com; posting-host=66.126.103.122; posting-account=ps2QrAMAAAA6_jCuRt2JEIpn5Otqf_w0 Xref: g2news1.google.com comp.lang.ada:16594 Date: 2007-07-24T07:55:00-07:00 List-Id: On Jul 24, 4:11 am, Stephen Leake wrote: > > I really have to question this. I tried it using GNAT on Linux, and > > (as I expected) Command_Name simply returns whatever was the first > > token I entered on the shell command line---i.e. argv[0] (which is > > what the Ada 95 manual hints that Command_Name should return). > > Yes, that is exactly what it does. > > I guess in the cases I use it, I always launch a program by specifying > its full path. > > That is typically the case for launching from an icon, for example. What's an icon? :) :) Seriously, I'm enougb of a dinosaur that I still use command lines for everything, most of the time. (Even on Windows.) I still think it's the coolest thing that I don't have to punch my commands onto Hollerith cards any more. > > ; that is the application > >> path. > > >> There may be a better solution in Ada 2005. > > > If we assume that Command_Name returns the name of some (executable) > > file that may or may not be a full path name, then > > Ada.Directories.Full_Name (Ada.Command_Line.Command_Name) should > > return the full path, > > if the default directory hasn't been changed with > > Ada.Directories.Set_Directory. > > Why should this depend on the "default directory"? LRM A.16 (71) says > Full_Name returns "the full name of the file" AARM A.16 (72.a): "Full name means that no abbreviations are used in the returned name, and that it is a full specification of the name. Thus, for Unix and Windows=AE, the result should be a full path that does not contain any "." or ".." directories. Typically, the default directory is used to fill in any missing information." Niklas already answered this. If you give it a simple file name, the only reasonable way it can expand this into a full file name is by using the current (default) directory, since the simple file name is a string that doesn't carry any magic dust that tells it what directory the string refers to. > . LRM A.16 (47) defines > "full name" as you would expect, with no reference to "default directory". It defines what the "full name" of an *external* *file* is, but that isn't enough to define what the "full name corresponding to a file *name*" [emphasis mine] is (A.16(72)), since a file name does not necessarily uniquely identify an external file. -- Adam