diff options
Diffstat (limited to 'lib/tempfile.rb')
-rw-r--r-- | lib/tempfile.rb | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/tempfile.rb b/lib/tempfile.rb index bf51ac2788..ed376a5032 100644 --- a/lib/tempfile.rb +++ b/lib/tempfile.rb @@ -28,13 +28,14 @@ class Tempfile < SimpleDelegator } end - def initialize(basename, tmpdir = '/tmp') + def initialize(basename, tmpdir = nil) umask = File.umask(0177) tmpname = lock = nil begin n = 0 while true begin + tmpdir ||= ENV['TMPDIR'] || ENV['TMP'] || ENV['TEMP'] || '/tmp' tmpname = sprintf('%s/%s.%d.%d', tmpdir, basename, $$, n) lock = tmpname + '.lock' unless File.exist?(lock) |