comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: How to get pathname of executable
Date: Wed, 14 Dec 2005 18:06:52 -0600
Date: 2005-12-14T18:06:52-06:00	[thread overview]
Message-ID: <oqydnTB7UawFLz3enZ2dnUVZ_tydnZ2d@megapath.net> (raw)
In-Reply-To: 439fbcd3$0$19908$626a54ce@news.free.fr

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1569 bytes --]

"Lionel Draghi" <Lionel.nospam.Draghi@Ada-France.org> wrote in message
news:439fbcd3$0$19908$626a54ce@news.free.fr...
> Dirk Heinrichs a �crit :
> > Marc A. Criley wrote:
> >
> >
> >>Dirk Heinrichs wrote:
> >>
> >>>I'm trying to find out how to get the complete pathname of an ada
> >>>executable on Linux. I already tried Ada.Command_Line.Command_Name, but
> >>>that only gives the executable's name as the user typed it. I want to
> >>>find out where it is stored in the filesystem so that it can load other
> >>>files from directories relative to its own directory.
...
>
> 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)
>
> (Warning, I did not check this code)

And if you want the full name of the directory, you need to use both:

     Ada.Directories.Full_Name (Ada.Directories.Containing_Directory
(Ada.Command_Line.Command_Name))

If your compiler supports this new package, it's recommended to use it
rather than implemented-defined packages, simply because it will make your
code more portable in the long run, and no less portable in the short run
(if some other compiler doesn't support Ada.Directories, then you might have
to change the code, but that other compiler is rather unlikely to support
GNAT-specific packages anyway, so this is no worse and likely better).

                     Randy.









  reply	other threads:[~2005-12-15  0:06 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-12-13 14:40 How to get pathname of executable Dirk Heinrichs
2005-12-13 15:26 ` Marc A. Criley
2005-12-13 15:57   ` Dirk Heinrichs
2005-12-14  6:34     ` Lionel Draghi
2005-12-15  0:06       ` Randy Brukardt [this message]
2005-12-15  9:30       ` Dirk Heinrichs
2005-12-15 10:26         ` Martin Dowie
2005-12-15 13:10           ` Dirk Heinrichs
2005-12-15 17:34             ` Pascal Obry
2005-12-15 22:42             ` Simon Wright
2005-12-16  6:56               ` Martin Dowie
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox