Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!apple!fernwood!uunet!mcsun!unido!laura!heike!klute From: klute@heike.informatik.uni-dortmund.de (Rainer Klute) Newsgroups: comp.sys.atari.st.tech Subject: Re: The program's name and path - how can I get them? Message-ID: <2729@laura.UUCP> Date: 17 Oct 90 13:17:43 GMT References: <1990Oct8.110346@heike.informatik.uni-dortmund.de> Sender: news@laura.UUCP Reply-To: klute@heike.informatik.uni-dortmund.de (Rainer Klute) Organization: University of Dortmund, Germany Lines: 47 Thanks to all how replied to my query. Here is an outline of what I think is the best solution. I implemented in Arcgsh 3.2 coming soon on comp.binaries.atari.st. First I try to find the program's path with the shel_find() function. The parameter is the basename of the resource file. (I know at this point that the resource file exists because it has been loaded with rsrc_load() already.) If shel_find() succeeds it returns either a full path or the filename as I handed it to shel_find. In the latter case the file is in the current directory on the current drive, and I can construct the full path myself. If shel_find() fails I do the same as shel_find() for the directories in the PATH environment variable: PathFind() takes a filename and searches all directories in the PATH for that file. If it is found its full path is returned. Here is a piece of source code from Arcgsh 3.2 showing the principle: strcpy (buffer, "arcgsh.rsc"); if (shel_find (buffer) != 0) { if (buffer[1] != ':') getpath (arcgshDirectory); else strcpy (arcgshDirectory, dirname (buffer)); i = strlen (arcgshDirectory) - 1; if (arcgshDirectory[i] != '\\') strcat (arcgshDirectory, "\\"); } else { if (PathFind (buffer) != 0) { strcpy (arcgshDirectory, dirname (buffer)); strcat (arcgshDirectory, "\\"); } else *arcgshDirectory = '\0'; }; -- Dipl.-Inform. Rainer Klute klute@irb.informatik.uni-dortmund.de Univ. Dortmund, IRB klute@unido.uucp, klute@unido.bitnet Postfach 500500 |)|/ Tel.: +49 231 755-4663 D-4600 Dortmund 50 |\|\ Fax : +49 231 755-2386