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-7-bit Path: g2news1.google.com!news4.google.com!out02a.usenetserver.com!news.usenetserver.com!in02.usenetserver.com!news.usenetserver.com!uns-out.usenetserver.com!news.usenetserver.com!pc03.usenetserver.com!news.flashnewsgroups.com-b7.4zTQh5tI3A!not-for-mail Newsgroups: comp.lang.ada Subject: Re: How to get the application path References: <46a456aa$0$25908$426a34cc@news.free.fr> <1185204459.328520.240930@z24g2000prh.googlegroups.com> From: Stephen Leake Date: Tue, 24 Jul 2007 07:11:58 -0400 Message-ID: User-Agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (windows-nt) Cancel-Lock: sha1:HsZonhkpYTSoF1f5oYfjD3xLOZE= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: abuse@flashnewsgroups.com Organization: FlashNewsgroups.com X-Trace: 72b6346a5de82759e00d422671 Xref: g2news1.google.com comp.lang.ada:16590 Date: 2007-07-24T07:11:58-04:00 List-Id: Adam Beneschan writes: > On Jul 23, 5:34 am, Stephen Leake > wrote: >> Rangdalf writes: >> > Hi, >> >> > In C# there is something like Application.startupPath. Is there a >> > package or function to get this path. >> > I can get the current directory but I need the application one. >> >> In Ada 95, Ada.Command_Line.Command_Name returns the executable name, >> which usually (not always) has the full path > > 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. > ; 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, Yes, this is the right solution. > 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". LRM A.16 (47) defines "full name" as you would expect, with no reference to "default directory". I'll update my code to use this, so it is more robust. -- -- Stephe