aboutsummaryrefslogtreecommitdiffstats
path: root/lib/tempfile.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-03-29 06:11:48 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-03-29 06:11:48 +0000
commitd0cb5c71ce3f179f14fddf5241cf0dcfe1599123 (patch)
treec18fd3ec24ca0e5bb6c0fd5423cad1e3420e4d49 /lib/tempfile.rb
parentd894e1d9301e4a87a42fa57be6492a9e01e5948f (diff)
downloadruby-d0cb5c71ce3f179f14fddf5241cf0dcfe1599123.tar.gz
* lib/tempfile.rb (Tempfile#open): re-open with same mode and
options as initialize. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27086 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/tempfile.rb')
-rwxr-xr-xlib/tempfile.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/tempfile.rb b/lib/tempfile.rb
index e1bccf0a90..79dd5cc02c 100755
--- a/lib/tempfile.rb
+++ b/lib/tempfile.rb
@@ -138,6 +138,7 @@ class Tempfile < DelegateClass(File)
if opts
mode |= opts.delete(:mode) || 0
opts[:perm] = perm
+ perm = nil
else
opts = perm
end
@@ -148,6 +149,9 @@ class Tempfile < DelegateClass(File)
ensure
self.class.rmdir(lock)
end
+ @mode = mode & ~(File::CREAT|File::EXCL)
+ perm or opts.freeze
+ @opts = opts
end
super(@tmpfile)
@@ -156,7 +160,7 @@ class Tempfile < DelegateClass(File)
# Opens or reopens the file with mode "r+".
def open
@tmpfile.close if @tmpfile
- @tmpfile = File.open(@tmpname, 'r+')
+ @tmpfile = File.open(@tmpname, @mode, @opts)
@data[1] = @tmpfile
__setobj__(@tmpfile)
end