2003-07-21 15:34:18 +00:00
|
|
|
#
|
|
|
|
# tmpdir - retrieve temporary directory path
|
|
|
|
#
|
|
|
|
# $Id$
|
|
|
|
#
|
|
|
|
|
|
|
|
class Dir
|
|
|
|
begin
|
|
|
|
require "Win32API"
|
|
|
|
max_pathlen = 260
|
|
|
|
t_path = ' '*(max_pathlen+1)
|
2003-07-22 01:53:58 +00:00
|
|
|
t_path = t_path[0, Win32API.new('kernel32', 'GetTempPath', 'LP', 'L').call(t_path.size, t_path)]
|
2003-07-21 15:34:18 +00:00
|
|
|
t_path.untaint
|
2003-07-22 01:53:58 +00:00
|
|
|
TMPDIR = File.expand_path(t_path)
|
2003-07-21 15:34:18 +00:00
|
|
|
rescue LoadError
|
|
|
|
if $SAFE > 0
|
|
|
|
TMPDIR = '/tmp'
|
|
|
|
else
|
2003-07-22 08:42:47 +00:00
|
|
|
TMPDIR = File.expand_path(ENV['TMPDIR']||ENV['TMP']||ENV['TEMP']||'/tmp')
|
2003-07-21 15:34:18 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
if __FILE__ == $0
|
|
|
|
puts Dir::TMPDIR
|
|
|
|
end
|