* lib/tmpdir.rb (Dir::tmpdir): test the current directory suitable for
temporary directory. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34988 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
5e3009aa45
commit
b681457f01
@ -1,3 +1,8 @@
|
|||||||
|
Mon Mar 12 20:19:25 2012 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
|
* lib/tmpdir.rb (Dir::tmpdir): test the current directory suitable for
|
||||||
|
temporary directory.
|
||||||
|
|
||||||
Mon Mar 12 20:08:16 2012 Tanaka Akira <akr@fsij.org>
|
Mon Mar 12 20:08:16 2012 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
* lib/fileutils.rb (fu_have_symlink?): specify TypeError for rescue
|
* lib/fileutils.rb (fu_have_symlink?): specify TypeError for rescue
|
||||||
|
@ -18,18 +18,21 @@ class Dir
|
|||||||
# Returns the operating system's temporary file path.
|
# Returns the operating system's temporary file path.
|
||||||
|
|
||||||
def Dir::tmpdir
|
def Dir::tmpdir
|
||||||
tmp = '.'
|
|
||||||
if $SAFE > 0
|
if $SAFE > 0
|
||||||
tmp = @@systmpdir
|
tmp = @@systmpdir
|
||||||
else
|
else
|
||||||
for dir in [ENV['TMPDIR'], ENV['TMP'], ENV['TEMP'], @@systmpdir, '/tmp']
|
tmp = nil
|
||||||
if dir and stat = File.stat(dir) and stat.directory? and stat.writable? and
|
for dir in [ENV['TMPDIR'], ENV['TMP'], ENV['TEMP'], @@systmpdir, '/tmp', '.']
|
||||||
|
next if !dir
|
||||||
|
dir = File.expand_path(dir)
|
||||||
|
if stat = File.stat(dir) and stat.directory? and stat.writable? and
|
||||||
(!stat.world_writable? or stat.sticky?)
|
(!stat.world_writable? or stat.sticky?)
|
||||||
tmp = dir
|
tmp = dir
|
||||||
break
|
break
|
||||||
end rescue nil
|
end rescue nil
|
||||||
end
|
end
|
||||||
File.expand_path(tmp)
|
raise ArgumentError, "could not find a temporary directory" if !tmp
|
||||||
|
tmp
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user