summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-05-24 22:58:18 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-05-24 22:58:18 +0000
commitc5c245554df58577560571150189a592da7d0640 (patch)
tree121404a6a8791aa6f807f675e4d96bebb1752ff9
parent6cbe0e0fd6dd99520f0695f318a6a501570d578c (diff)
* 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
-rw-r--r--ChangeLog5
-rw-r--r--lib/tempfile.rb25
2 files changed, 19 insertions, 11 deletions
diff --git a/ChangeLog b/ChangeLog
index 660f7346e1..076b1a856f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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>
* spec/README: update the description.
diff --git a/lib/tempfile.rb b/lib/tempfile.rb
index 94dd0ce532..46a5605e52 100644
--- a/lib/tempfile.rb
+++ b/lib/tempfile.rb
@@ -141,12 +141,9 @@ class Tempfile < DelegateClass(File)
else
opts = perm
end
- lock = self.class.lock_tempfile(tmpname)
- begin
+ self.class.locking(tmpname) do
@data[1] = @tmpfile = File.open(tmpname, mode, opts)
@data[0] = @tmpname = tmpname
- ensure
- self.class.unlock_tempfile(lock)
end
@mode = mode & ~(File::CREAT|File::EXCL)
perm or opts.freeze
@@ -327,16 +324,22 @@ class Tempfile < DelegateClass(File)
# :stopdoc:
- # makes lock for +tmpname+ and returns the lock.
- def lock_tempfile(tmpname)
+ # yields with locking for +tmpname+ and returns the result of the
+ # block.
+ def locking(tmpname)
lock = tmpname + '.lock'
- Dir.mkdir(lock)
- lock
+ mkdir(lock)
+ yield
+ ensure
+ rmdir(lock) if lock
end
- # unlock the lock made by _lock_tempfile_.
- def unlock_tempfile(lock)
- Dir.rmdir(lock)
+ def mkdir(*args)
+ Dir.mkdir(*args)
+ end
+
+ def rmdir(*args)
+ Dir.rmdir(*args)
end
end
end