From: Markus E Leypold <development-2006-8ecbb5cc8aREMOVETHIS@ANDTHATm-e-leypold.de>
Subject: Re: How to get the application path
Date: Mon, 23 Jul 2007 18:27:28 +0200
Date: 2007-07-23T18:27:28+02:00 [thread overview]
Message-ID: <sxmyxnrspb.fsf@hod.lan.m-e-leypold.de> (raw)
In-Reply-To: 1185204459.328520.240930@z24g2000prh.googlegroups.com
> On Jul 23, 5:34 am, Stephen Leake <stephen_le...@stephe-leake.org>
> wrote:
>> Rangdalf <rangd...@hotmail.com> 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
next prev parent reply other threads:[~2007-07-23 16:27 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-23 7:20 How to get the application path Rangdalf
2007-07-23 12:06 ` qouify
2007-07-23 12:34 ` Stephen Leake
2007-07-23 15:27 ` Adam Beneschan
2007-07-23 16:27 ` Markus E Leypold [this message]
2007-07-24 11:14 ` Stephen Leake
2007-07-24 11:35 ` Markus E Leypold
2007-07-23 16:37 ` Dmitry A. Kazakov
2007-07-24 11:11 ` Stephen Leake
2007-07-24 11:44 ` Niklas Holsti
2007-07-24 19:33 ` Randy Brukardt
2007-07-24 20:30 ` Niklas Holsti
2007-07-24 22:01 ` Markus E Leypold
2007-07-24 21:56 ` Markus E Leypold
2007-07-26 10:39 ` Stephen Leake
2007-07-30 23:38 ` Markus E.L.
2007-08-02 4:31 ` Randy Brukardt
2007-08-02 22:23 ` Markus E.L. 2
2007-07-24 14:07 ` Robert A Duff
2007-07-24 14:58 ` Adam Beneschan
2007-07-25 10:05 ` Stephen Leake
2007-07-24 14:55 ` Adam Beneschan
2007-07-24 15:41 ` Markus E Leypold
2007-07-25 19:13 ` Randy Brukardt
2007-07-23 18:51 ` Georg Bauhaus
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox