Class: Raemon::Util
- Inherits:
-
Object
- Object
- Raemon::Util
- Defined in:
- lib/raemon/util.rb
Class Method Summary collapse
-
.tmpio ⇒ Object
Creates and returns a new File object.
Class Method Details
.tmpio ⇒ Object
Creates and returns a new File object. The File is unlinked immediately, switched to binary mode, and userspace output buffering is disabled. Method pulled from Unicorn library.
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/raemon/util.rb', line 8 def tmpio begin fp = File.open("#{Dir::tmpdir}/#{rand}", File::RDWR | File::CREAT | File::EXCL, 0600) rescue Errno::EEXIST retry end File.unlink(fp.path) fp.binmode fp.sync = true fp end |