Skip to content
An alternative for generating temporary files with Ruby
Ruby
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
lib/file
test
CHANGES
MANIFEST
README
Rakefile
file-temp.gemspec

README

== Description
   The file-temp library is an alternate way to handle tempfile generation.

== Requirements
   ffi 1.0.0 or later

== Installation
   gem install file-temp

== Synopsis
   require 'file/temp'

   fh = File::Temp.new
   fh.puts "hello"
   fh.close # => Tempfile automatically deleted

   fh = File::Temp.new(false)
   fh.puts "world"
   fh.close # => Tempfile still on your filesystem

== Motivation
   Ruby's tempfile.rb is overwrought and susceptible to race conditions.
   This library uses your system's native tmpfile() or mkstemp() functions
   instead of trying to handle race conditions manually via pure Ruby.
   
   This library is also more secure because it restricts file permission via
   umask() for files created with mkstemp().

   Finally, this library subclasses the File class. This means you get almost
   exactly the same interface as the File class. The only difference is the
   constructor.

== JRuby
   The implementation for JRuby uses the Java API, not the C API. The
   temporary file name generated by Java is different than the C version,
   since it uses a GUID instead of the 'XXXXXX' template, but the
   interface is otherwise identical.

   There is one test failure with JRuby (threaded tempfile creation). I am
   not sure why, as sample code seems to work fine. Help wanted.

== MS Windows
   You may need to use the mingw build in order to use this library.

== License
   Artistic 2.0

== Copyright
   (C) 2007-2014 Daniel J. Berger
   All Rights Reserved

== Warranty
   This library is provided "as is" and without any express or
   implied warranties, including, without limitation, the implied
   warranties of merchantability and fitness for a particular purpose.

== Author
   Daniel J. Berger

== See also
   tmpfile(), mkstemp(), tmpnam()
Something went wrong with that request. Please try again.