tmpio: drop the "size" method
[unicorn.git] / lib / unicorn / tmpio.rb
blobc97979ae4e05520e24932d50ba1386902e3424ea
1 # -*- encoding: binary -*-
2 # :stopdoc:
3 require 'tmpdir'
5 # some versions of Ruby had a broken Tempfile which didn't work
6 # well with unlinked files.  This one is much shorter, easier
7 # to understand, and slightly faster.
8 class Unicorn::TmpIO < File
10   # creates and returns a new File object.  The File is unlinked
11   # immediately, switched to binary mode, and userspace output
12   # buffering is disabled
13   def self.new
14     fp = begin
15       super("#{Dir::tmpdir}/#{rand}", RDWR|CREAT|EXCL, 0600)
16     rescue Errno::EEXIST
17       retry
18     end
19     unlink(fp.path)
20     fp.binmode
21     fp.sync = true
22     fp
23   end
24 end