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:
parent
3f5fbc6c34
commit
d9eae80011
3 changed files with 10 additions and 2 deletions
|
@ -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>
|
Wed Nov 11 12:54:02 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* hash.c (ruby_setenv): use ruby_strdup().
|
* hash.c (ruby_setenv): use ruby_strdup().
|
||||||
|
|
|
@ -133,9 +133,11 @@ class Tempfile < DelegateClass(File)
|
||||||
|
|
||||||
create(basename, *rest) do |tmpname, n, opts|
|
create(basename, *rest) do |tmpname, n, opts|
|
||||||
lock = tmpname + '.lock'
|
lock = tmpname + '.lock'
|
||||||
|
mode = opts.delete(:mode) || 0
|
||||||
|
mode = File::RDWR|File::CREAT|File::EXCL|mode
|
||||||
self.class.mkdir(lock)
|
self.class.mkdir(lock)
|
||||||
begin
|
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
|
@data[0] = @tmpname = tmpname
|
||||||
ensure
|
ensure
|
||||||
self.class.rmdir(lock)
|
self.class.rmdir(lock)
|
||||||
|
|
|
@ -152,7 +152,7 @@ class Dir
|
||||||
n = nil
|
n = nil
|
||||||
begin
|
begin
|
||||||
path = File.expand_path(make_tmpname(basename, n), tmpdir)
|
path = File.expand_path(make_tmpname(basename, n), tmpdir)
|
||||||
yield(path, n, opts)
|
yield(path, n, *opts)
|
||||||
rescue Errno::EEXIST
|
rescue Errno::EEXIST
|
||||||
n ||= 0
|
n ||= 0
|
||||||
n += 1
|
n += 1
|
||||||
|
|
Loading…
Reference in a new issue