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.3 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,814d0ec938d6e4da X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-04-24 03:03:04 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!fr.clara.net!heighliner.fr.clara.net!freenix!enst!enst.fr!not-for-mail From: "Grein, Christoph" Newsgroups: comp.lang.ada Subject: Re: How to find directory where the program is? Date: Wed, 24 Apr 2002 11:44:58 +0200 (MET DST) Organization: ENST, France Sender: comp.lang.ada-admin@ada.eu.org Message-ID: Reply-To: comp.lang.ada@ada.eu.org NNTP-Posting-Host: marvin.enst.fr Mime-Version: 1.0 Content-Type: TEXT/plain; charset=US-ASCII Content-Transfer-Encoding: QUOTED-PRINTABLE X-Trace: avanie.enst.fr 1019642584 13742 137.194.161.2 (24 Apr 2002 10:03:04 GMT) X-Complaints-To: usenet@enst.fr NNTP-Posting-Date: Wed, 24 Apr 2002 10:03:04 +0000 (UTC) Return-Path: X-Authentication-Warning: mail.eurocopter.com: uucp set sender to using -f Content-MD5: zpyAnDusS9PgEOsYgdHbHg== X-Mailer: dtmail 1.2.1 CDE Version 1.2.1 SunOS 5.6 sun4u sparc Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org X-Mailman-Version: 2.0.8 Precedence: bulk X-Reply-To: "Grein, Christoph" List-Help: List-Post: List-Subscribe: , List-Id: comp.lang.ada mail<->news gateway List-Unsubscribe: , Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org Xref: archiver1.google.com comp.lang.ada:23040 Date: 2002-04-24T11:44:58+02:00 Observation for Ada.Command_Line.Command_Name: Win98: Always the full path and extension are returned. WinNT: Only the name as entered on the command line is returned. Thus we have to look for a portable way. RM A.15(16) leaves the string completely implementation defined. RM A.8.2(22) requires the full name to be returned. Thanks to Randy Brukardt for this hint (a long time ago, about Jan = 2001). It may however not be possible to open the executable file with = Text_IO. function Full_Name return String is -- Retrieve the full name via RM A.8.2(22). Command: String renames Ada.Command_Line.Command_Name; use Ada.Text_IO; Executable: File_Type; begin if Extension (Command) =3D "" then Open (Executable, In_File, Command & ".exe"); else Open (Executable, In_File, Command); end if; declare Full_Name: String renames Name (Executable); begin Close (Executable); return Full_Name; end; exception when Name_Error =3D> -- file not found return ""; -- set error condition end Full_Name;