From: Brian Candler Date: 2007-02-08T21:43:20+09:00 Subject: Re: method to get (Linux) user home path On Thu, Feb 08, 2007 at 07:52:41PM +0900, Erik Veenstra wrote: > These are my personal implementations of Dir.home and Dir.temp. ruby has the latter included as standard. require 'tmpdir' puts Dir.tmpdir Here's the implementation from tmpdir.rb: ## # Returns the operating system's temporary file path. def Dir::tmpdir tmp = '.' if $SAFE > 0 tmp = @@systmpdir else for dir in [ENV['TMPDIR'], ENV['TMP'], ENV['TEMP'], ENV['USERPROFILE'], @@systmpdir, '/tmp'] if dir and File.directory?(dir) and File.writable?(dir) tmp = dir break end end end File.expand_path(tmp) end