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 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: Markus E Leypold Organization: N/A Date: Mon, 23 Jul 2007 18:27:28 +0200 Message-ID: User-Agent: Some cool user agent (SCUG) Cancel-Lock: sha1:6+TqlerRhhSwPJWcuSLnUrowOH8= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii NNTP-Posting-Host: 88.72.251.9 X-Trace: news.arcor-ip.de 1185207392 88.72.251.9 (23 Jul 2007 18:16:32 +0200) X-Complaints-To: abuse@arcor-ip.de Path: g2news1.google.com!news1.google.com!news2.google.com!news.glorb.com!feeder.news-service.com!multikabel.net!feed10.multikabel.net!feed.xsnews.nl!border-1.ams.xsnews.nl!newsfeed.kamp.net!newsfeed.kamp.net!news.unit0.net!newsfeed.arcor-ip.de!news.arcor-ip.de!not-for-mail Xref: g2news1.google.com comp.lang.ada:16558 Date: 2007-07-23T18:27:28+02:00 List-Id: > 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). > > Maybe things are different on Windows, but the original poster didn't > refer to any particular operating system. > > ; 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 Command_Name returns the first element of argv[]. There is a convention that this is the name of the executable. But since argv[0] is set by the invoking process, it might be anything: The full path of an executable, just the executable name (which it usually is on Unix with the Bourne shell when path searching is in effect) or _anything_ else. BTW: Is it possible the OP doesn't want the path to the executable, but rather the directory which becomes /became the wurrent directory of the application at startup? Isn't that what Application.startupPath is on Windows? > 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. To extract just the directory > name, without the base name, Ada.Directories.Containing_Directory > (Ada.Directories.Full_Name (Ada.Command_Line.Command_Name)) should > work. Regards -- Markus