diff --git a/ChangeLog b/ChangeLog index 33d01613c8..061352aca8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Wed Nov 11 19:17:35 2009 Nobuyoshi Nakada + + * lib/tempfile.rb (Tempfile#initialize): merge mode option. + + * lib/tmpdir.rb (Dir::Tmpname#create): splat options. + Wed Nov 11 12:54:02 2009 Nobuyoshi Nakada * hash.c (ruby_setenv): use ruby_strdup(). diff --git a/lib/tempfile.rb b/lib/tempfile.rb index 4ebeea28a1..7024bd9bdb 100755 --- a/lib/tempfile.rb +++ b/lib/tempfile.rb @@ -133,9 +133,11 @@ class Tempfile < DelegateClass(File) create(basename, *rest) do |tmpname, n, opts| lock = tmpname + '.lock' + mode = opts.delete(:mode) || 0 + mode = File::RDWR|File::CREAT|File::EXCL|mode self.class.mkdir(lock) begin - @data[1] = @tmpfile = File.open(tmpname, File::RDWR|File::CREAT|File::EXCL, 0600, *opts) + @data[1] = @tmpfile = File.open(tmpname, mode, 0600, *opts) @data[0] = @tmpname = tmpname ensure self.class.rmdir(lock) diff --git a/lib/tmpdir.rb b/lib/tmpdir.rb index fafe120b3e..32befa3e8a 100644 --- a/lib/tmpdir.rb +++ b/lib/tmpdir.rb @@ -152,7 +152,7 @@ class Dir n = nil begin path = File.expand_path(make_tmpname(basename, n), tmpdir) - yield(path, n, opts) + yield(path, n, *opts) rescue Errno::EEXIST n ||= 0 n += 1