1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* lib/tmpdir.rb (tmpdir): new method. remove TMPDIR.

use GetSystemWindowsDirectory(GetSystemDirectory), not GetTempPath.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4129 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
eban 2003-07-23 16:37:35 +00:00
parent 231247c010
commit 02f036ddbc
5 changed files with 39 additions and 18 deletions

View file

@ -1,3 +1,8 @@
Thu Jul 24 01:32:04 2003 WATANABE Hirofumi <eban@ruby-lang.org>
* lib/tmpdir.rb (tmpdir): new method. remove TMPDIR.
use GetSystemWindowsDirectory(GetSystemDirectory), not GetTempPath.
Thu Jul 24 01:08:43 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
* ext/openssl: imported.

View file

@ -110,7 +110,7 @@ class CGI
end
def initialize(session, option={})
dir = option['tmpdir'] || Dir::TMPDIR
dir = option['tmpdir'] || Dir::tmpdir
prefix = option['prefix'] || ''
id = session.session_id
unless check_id(id)

View file

@ -53,7 +53,7 @@ module DRb
Max_try = 10
private
def self.temp_server
tmpdir = Dir::TMPDIR
tmpdir = Dir::tmpdir
n = 0
while true
begin

View file

@ -18,10 +18,10 @@ class Tempfile < SimpleDelegator
# object works just like a File object.
#
# If tmpdir is omitted, the temporary directory is determined by
# Dir::TMPDIR provided by 'tmpdir.rb'.
# Dir::tmpdir provided by 'tmpdir.rb'.
# When $SAFE > 0 and the given tmpdir is tainted, it uses
# /tmp. (Note that ENV values are tainted by default)
def initialize(basename, tmpdir=Dir::TMPDIR)
def initialize(basename, tmpdir=Dir::tmpdir)
if $SAFE > 0 and tmpdir.tainted?
tmpdir = '/tmp'
end

View file

@ -5,22 +5,38 @@
#
class Dir
@@systmpdir = '/tmp'
begin
require "Win32API"
require 'Win32API'
max_pathlen = 260
t_path = ' '*(max_pathlen+1)
t_path = t_path[0, Win32API.new('kernel32', 'GetTempPath', 'LP', 'L').call(t_path.size, t_path)]
t_path.untaint
TMPDIR = File.expand_path(t_path)
rescue LoadError
if $SAFE > 0
TMPDIR = '/tmp'
else
TMPDIR = File.expand_path(ENV['TMPDIR']||ENV['TMP']||ENV['TEMP']||'/tmp')
windir = ' '*(max_pathlen+1)
begin
getdir = Win32API.new('kernel32', 'GetSystemWindowsDirectory', 'PL', 'L')
rescue RuntimeError
getdir = Win32API.new('kernel32', 'GetSystemDirectory', 'PL', 'L')
end
getdir.call(windir, windir.size)
windir = File.expand_path(windir.rstrip.untaint)
temp = File.join(windir, 'temp')
@@systmpdir = temp if File.directory?(temp) and File.writable?(temp)
rescue LoadError
end
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
end
if __FILE__ == $0
puts Dir::TMPDIR
end