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> <46a5e4e1$0$27850$39db0f71@news.song.fi> From: Markus E Leypold Organization: N/A Date: Tue, 24 Jul 2007 23:56:47 +0200 Message-ID: <0kbqe1zcrk.fsf@hod.lan.m-e-leypold.de> User-Agent: Some cool user agent (SCUG) Cancel-Lock: sha1:VJn/KUkc1n3+y82PwU7mSV0hm/U= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii NNTP-Posting-Host: 88.72.211.100 X-Trace: news.arcor-ip.de 1185313547 88.72.211.100 (24 Jul 2007 23:45:47 +0200) X-Complaints-To: abuse@arcor-ip.de Path: g2news2.google.com!news3.google.com!proxad.net!feeder1-2.proxad.net!62.111.101.3.MISMATCH!news.germany.com!news.unit0.net!newsfeed.arcor-ip.de!news.arcor-ip.de!not-for-mail Xref: g2news2.google.com comp.lang.ada:1161 Date: 2007-07-24T23:56:47+02:00 List-Id: > "Niklas Holsti" wrote in message > news:46a5e4e1$0$27850$39db0f71@news.song.fi... > ... >> If the Command_Name is simply "bong.exe", you cannot expect Full_Name to >> search through the file system to find the directory that contains >> "bong.exe". There could be several such directories. Full_Name cannot >> use the PATH envinroment variable to find the directory because PATH >> only applies to executable files and Full_Name should apply to all files. > > Well, on Janus/Ada the Path applies to all files (Open searches the path if > given a simple file name). This cames from inadequate DOS documentation when > we were building our compiler in the early 1980's, and an unwillingness to > break existing code. > > Anyway, in Janus/Ada 95, all you do is open "Bong.Exe" and then ask for the > Name; that will definitely find the file and return its full path. Not sure > whether the Amendment updates will change that (probably not, it would break > all of our code...). > >> If Command_Name gives you only the simple name, and you want the full >> name, I think you must use Ada.Environment_Variables to get the value of >> PATH and then scan the PATH directories for the Command_Name. But then >> it would be simpler to just put the "application path" into a well-named >> environment variable and forget about Command_Name. > > Yes, that's how you'd have to do it in general. Yuck. (At least you can do > that with Ada.Directories.) I don't see how an Ada program could put the > application path into an environment variable, though; this is the sort of > thing that I wouldn't want to have to go outside of Ada to do (because it > would depend on the user "doing the right thing", and we all know that users > often don't do the right thing). Now, on Unix I'd just put a shell script wrapper in place of the executable: MYPATH="$0" MYAPP="$(which $MYPATH.bin)" # locate the executable proper export EXE_PATH="$MYPATH" exec $MYAPP "$@" (untested, mind you). That would even put the full path in argv[0]. The power of shell script wrappers in Unix is usually underestimated. Regards -- Markus > > Randy.