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.{mkdir,rmdir}): revert for backward

compatibility.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31723 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2011-05-24 22:58:18 +00:00
parent 6cbe0e0fd6
commit c5c245554d
2 changed files with 19 additions and 11 deletions

View file

@ -1,3 +1,8 @@
Wed May 25 07:58:14 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/tempfile.rb (Tempfile.{mkdir,rmdir}): revert for backward
compatibility.
Wed May 25 07:13:12 2011 Nobuyoshi Nakada <nobu@ruby-lang.org> Wed May 25 07:13:12 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
* spec/README: update the description. * spec/README: update the description.

View file

@ -141,12 +141,9 @@ class Tempfile < DelegateClass(File)
else else
opts = perm opts = perm
end end
lock = self.class.lock_tempfile(tmpname) self.class.locking(tmpname) do
begin
@data[1] = @tmpfile = File.open(tmpname, mode, opts) @data[1] = @tmpfile = File.open(tmpname, mode, opts)
@data[0] = @tmpname = tmpname @data[0] = @tmpname = tmpname
ensure
self.class.unlock_tempfile(lock)
end end
@mode = mode & ~(File::CREAT|File::EXCL) @mode = mode & ~(File::CREAT|File::EXCL)
perm or opts.freeze perm or opts.freeze
@ -327,16 +324,22 @@ class Tempfile < DelegateClass(File)
# :stopdoc: # :stopdoc:
# makes lock for +tmpname+ and returns the lock. # yields with locking for +tmpname+ and returns the result of the
def lock_tempfile(tmpname) # block.
def locking(tmpname)
lock = tmpname + '.lock' lock = tmpname + '.lock'
Dir.mkdir(lock) mkdir(lock)
lock yield
ensure
rmdir(lock) if lock
end end
# unlock the lock made by _lock_tempfile_. def mkdir(*args)
def unlock_tempfile(lock) Dir.mkdir(*args)
Dir.rmdir(lock) end
def rmdir(*args)
Dir.rmdir(*args)
end end
end end
end end