summaryrefslogtreecommitdiff
path: root/lib/tempfile.rb
diff options
context:
space:
mode:
authorakira <akira@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-07-07 15:18:00 +0000
committerakira <akira@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-07-07 15:18:00 +0000
commitdbc7ba14a0087214fbaa4df3cddb3890fa155f61 (patch)
tree7c803d755fc56cdd870a0ae10ea173332ff727f4 /lib/tempfile.rb
parent10b0f97ae9cbca50d01476a7dff184dcef058b9b (diff)
* lib/tempfile.rb (Tempfile::initialize): got out code of
generating tmpname. [ruby-dev:23832][ruby-dev:23837] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6598 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/tempfile.rb')
-rw-r--r--lib/tempfile.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/tempfile.rb b/lib/tempfile.rb
index 9333505..6eb11be 100644
--- a/lib/tempfile.rb
+++ b/lib/tempfile.rb
@@ -33,7 +33,7 @@ class Tempfile < DelegateClass(File)
Thread.critical = true
begin
- tmpname = sprintf('%s/%s%d.%d', tmpdir, basename, $$, n)
+ tmpname = File.join(tmpdir, make_tmpname(basename, n))
lock = tmpname + '.lock'
n += 1
end while @@cleanlist.include?(tmpname) or
@@ -66,6 +66,11 @@ class Tempfile < DelegateClass(File)
Dir.rmdir(lock)
end
+ def make_tmpname(basename, n)
+ sprintf('%s%d.%d', basename, $$, n)
+ end
+ private :make_tmpname
+
# Opens or reopens the file with mode "r+".
def open
@tmpfile.close if @tmpfile