Class: Dir

Inherits:
Object
  • Object
show all
Defined in:
lib/tmpdir.rb

Overview

tmpdir - retrieve temporary directory path

$Id$

Constant Summary collapse

@@systmpdir =
'/tmp'

Class Method Summary collapse

Class Method Details

.tmpdirObject

Returns the operating system’s temporary file path.



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/tmpdir.rb', line 30

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