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,eda9cd0ad906c54b X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!news3.google.com!news.glorb.com!newsgate.cistron.nl!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed1.swip.net!swipnet!newsfeed1.funet.fi!newsfeeds.funet.fi!nntp.inet.fi!inet.fi!newsfeed1.nokia.com!news1.nokia.com!not-for-mail From: Dirk Heinrichs Subject: Re: How to get pathname of executable Newsgroups: comp.lang.ada References: <4d4f4$439ee80e$49955ab$26123@ALLTEL.NET> <439fbcd3$0$19908$626a54ce@news.free.fr> Organization: Capgemini Deutschland GmbH User-Agent: KNode/0.10 MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8Bit Message-ID: Date: Thu, 15 Dec 2005 09:30:09 GMT NNTP-Posting-Host: 172.25.104.26 X-Complaints-To: newsmaster@nokia.com X-Trace: news1.nokia.com 1134639009 172.25.104.26 (Thu, 15 Dec 2005 11:30:09 EET) NNTP-Posting-Date: Thu, 15 Dec 2005 11:30:09 EET Xref: g2news1.google.com comp.lang.ada:6883 Date: 2005-12-15T09:30:09+00:00 List-Id: Lionel Draghi wrote: > If using vendor specifics is a problem, and if your compiler provides > Ada 05 extensions, you may try: > Ada.Directories.Full_Name (Ada.Command_Line.Command_Name) > > And if you're only interested in the directory: > Ada.Directories.Containing_Directory (Ada.Command_Line.Command_Name) The GNAT GPL edition doesn't provide this, yet. But as soon as it does, I will use it. In the meantime, I use this code (UStrings is taken from the Lovelace tutorial): with UStrings; with GNAT.OS_Lib; with GNAT.Directory_Operations; use UStrings, GNAT.OS_Lib, GNAT.Directory_Operations; function Get_Exec_Path(Exec_Name : String) return UString is Me : UString := ""; Current_Dir : String := Get_Current_Dir; begin -- If Exec_name is an absolut path -> ready if Is_Absolute_Path(Exec_Name) then Me := U(Exec_Name); else -- Normalize current dir + Exec_name and see if the result -- is a regular file Me := U(Normalize_Pathname(Current_Dir & "/" & Exec_Name, Resolve_Links=>False)); if not Is_Regular_File(S(Me)) then -- Last chance: locate it on $PATH Me := U(Locate_Exec_On_Path(Exec_Name).all); end if; end if; return Me; end Get_Exec_Path; I call this function with Ada.Command_Line.Command_Name as input parameter. Only thing left is to get the directory part out of this, but that shouldn't be so hard. Thanks a lot... Dirk -- Dirk Heinrichs | Tel: +49 (0)162 234 3408 Configuration Manager | Fax: +49 (0)211 47068 111 Capgemini Deutschland | Mail: dirk.heinrichs@capgemini.com Hambornerstra�e 55 | Web: http://www.capgemini.com D-40472 D�sseldorf | ICQ#: 110037733 GPG Public Key C2E467BB | Keyserver: www.keyserver.net