On Tue, Jan 03, 2012 at 11:54:18PM +1100, Ben Coman wrote:
Esteban Lorenzano wrote:
El 02/01/2012, a las 4:39p.m., David T. Lewis escribi?:
Real problem then is:
we don't have a way to get the executable name
or
getSystemAttribute: comment is wrong :)
On a unix VM, it answers the full path to the executable, which is in agreement with the comment. For example:
Smalltalk getSystemAttribute: 0 ==> '/usr/local/lib/squeak/4.7.18-2505/squeakvm'
Maybe is is more complicated for Mac, but wasn't there some discussion about it on vm-dev a while back?
I don't remember :) so, how can we solve this? of course, it is not a problem to make getSystemAttribute: 0 answer argv[0], but that's not the expected behavior... we can be making a mistake, because it should answer vm path, no vm fullName. I can add a 10XX number to answer vm full name, but that will lead to consistency problems inside the image... I really don't know how to proceed :(
Esteban
Esteban,
I am not sure of the semantics within Smalltalk, but within both Windows & Linux "full path" includes the filename. Examples...
Linux `which` command [1] "...printing the full path when used from a script"
echo `which q2` /home/carlo/bin/q2
Windows Path.GetFullPath method [2] "Returns the absolute path for the specified path string." // GetFullPath('mydir') returns 'C:\temp\Demo\mydir' // GetFullPath('myfile.ext') returns 'C:\temp\Demo\myfile.ext'
From browsing around it does seem harder on OSX to determine the path to the current executable [3,4,5,6] but I'm not qualified to comment.
In the unix VM (see platforms/unix/vm/sqUnixMain.c), it is done using argv[0] and the realpath() function. In other words, take the program name from the command line, and pass it though realpath() to resolve symbolic links. I don't know if this approach works on OS X though. Dave
cheers, Ben
[1] http://linux.die.net/man/1/which [2] http://msdn.microsoft.com/en-us/library/system.io.path.getfullpath.aspx [3] http://stackoverflow.com/questions/799679/programatically-retrieving-the-abs... [4] http://stackoverflow.com/questions/1023306/finding-current-executables-path-... [5] http://stackoverflow.com/questions/933850/how-to-find-the-location-of-the-ex... [6] http://stackoverflow.com/questions/3200651/application-path-location-in-ms-w...