Twitter Updates

Monday, 27 April 2009

Ruby Shoes, Get full path of current application

After reading this post [1] I though that [2] would return the full path, as the url suggest it is only a relative path. For Ruby scripts executing under Shoes the current dir can change so it is always best to refer to a full path. The short script at [3] should give just that.

[1] http://stackoverflow.com/questions/757455/relative-file-paths
[2] File.dirname($PROGRAM_NAME)

[3]:
def getFullPath
modulepath = File.expand_path($PROGRAM_NAME)
modulepath = $modulepath.gsub($PROGRAM_NAME,"")
return modulepath
end

No comments: