Parent

Methods

Class/Module Index [+]

Quicksearch

PhusionPassenger::Utils::TmpIO

some versions of Ruby had a broken Tempfile which didn’t work well with unlinked files. This one is much shorter, easier to understand, and slightly faster.

Public Class Methods

new(namespace, options = nil) click to toggle source

creates and returns a new File object. The File is unlinked immediately, switched to binary mode, and userspace output buffering is disabled

# File lib/phusion_passenger/utils/tmpio.rb, line 15
def self.new(namespace, options = nil)
  if options
    mode   = options[:mode] || RDWR
    binary = options.fetch(:binary, true)
    suffix = options[:suffix]
    unlink_immediately = options.fetch(:unlink_immediately, true)
  else
    mode   = RDWR
    binary = true
    suffix = nil
    unlink_immediately = true
  end
  fp = begin
    super("#{Dir::tmpdir}/#{namespace}-#{rand(0x100000000).to_s(36)}#{suffix}", mode | CREAT | EXCL, 0600)
  rescue Errno::EEXIST
    retry
  end
  unlink(fp.path) if unlink_immediately
  fp.binmode if binary
  fp.sync = true
  fp
end

Public Instance Methods

size() click to toggle source

for easier env compatibility with Rack <= 1.1

# File lib/phusion_passenger/utils/tmpio.rb, line 39
def size
  stat.size
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.