ruby-changes:22939
From: akr <ko1@a...>
Date: Mon, 12 Mar 2012 20:19:54 +0900 (JST)
Subject: [ruby-changes:22939] akr:r34988 (trunk): * lib/tmpdir.rb (Dir::tmpdir): test the current directory suitable for
akr 2012-03-12 20:19:42 +0900 (Mon, 12 Mar 2012) New Revision: 34988 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=34988 Log: * lib/tmpdir.rb (Dir::tmpdir): test the current directory suitable for temporary directory. Modified files: trunk/ChangeLog trunk/lib/tmpdir.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 34987) +++ ChangeLog (revision 34988) @@ -1,3 +1,8 @@ +Mon Mar 12 20:19:25 2012 Tanaka Akira <akr@f...> + + * lib/tmpdir.rb (Dir::tmpdir): test the current directory suitable for + temporary directory. + Mon Mar 12 20:08:16 2012 Tanaka Akira <akr@f...> * lib/fileutils.rb (fu_have_symlink?): specify TypeError for rescue Index: lib/tmpdir.rb =================================================================== --- lib/tmpdir.rb (revision 34987) +++ lib/tmpdir.rb (revision 34988) @@ -18,18 +18,21 @@ # 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'], @@systmpdir, '/tmp'] - if dir and stat = File.stat(dir) and stat.directory? and stat.writable? and + tmp = nil + 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?) tmp = dir break end rescue nil end - File.expand_path(tmp) + raise ArgumentError, "could not find a temporary directory" if !tmp + tmp end end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/