require ‘tempfile’
f = Tempfile.open ‘tmp’
will open f in text mode (mode = ‘w’, not ‘wb’). Any non-hacky way to
open this in binary mode? I can, of course, make f, close it and open
it as a real file - it’s just this is not atomic.
require ‘tempfile’
f = Tempfile.open ‘tmp’
will open f in text mode (mode = ‘w’, not ‘wb’). Any non-hacky way to
open this in binary mode? I can, of course, make f, close it and open
it as a real file - it’s just this is not atomic.
On Oct 9, 12:00 pm, [email protected] wrote:
require ‘tempfile’
f = Tempfile.open ‘tmp’will open f in text mode (mode = ‘w’, not ‘wb’). Any non-hacky way to
open this in binary mode? I can, of course, make f, close it and open
it as a real file - it’s just this is not atomic.
Not that I can see.
May I suggest file-temp? It opens in binary mode by default:
http://raa.ruby-lang.org/project/file-temp
Regards,
Dan
On Oct 9, 2007, at 1:00 PM, [email protected] wrote:
require ‘tempfile’
f = Tempfile.open ‘tmp’will open f in text mode (mode = ‘w’, not ‘wb’). Any non-hacky way to
open this in binary mode? I can, of course, make f, close it and open
it as a real file - it’s just this is not atomic.
You can switch it to binary mode after it’s open:
#!/usr/bin/env ruby -wKU
require “tempfile”
f = Tempfile.new “binary”
f.binmode # switch to binary mode
END
James Edward G. II
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs