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

* lib/tempfile.rb (Tempfile#initialize): merge mode option.

* lib/tmpdir.rb (Dir::Tmpname#create): splat options.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25720 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2009-11-11 10:17:36 +00:00
parent 3f5fbc6c34
commit d9eae80011
3 changed files with 10 additions and 2 deletions

View file

@ -1,3 +1,9 @@
Wed Nov 11 19:17:35 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
* 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 <nobu@ruby-lang.org>
* hash.c (ruby_setenv): use ruby_strdup().

View file

@ -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)

View file

@ -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