Problem subclassing IO and writing on Windows

Hi all,

Windows XP Pro
Ruby 1.8.2

The following snippet dies on Windows with:

subtest.rb:8:in `write': not opened for writing (IOError)
from subtest.rb:8:in `write_stuff'
from subtest.rb:14

Works fine on *nix. Am I doing something wrong? Or is this a bug?

# subtest.rb
class MyIO < IO
   def initialize(arg)
      super(arg)
      binmode
   end
   
   def write_stuff
      write("Hello World")
   end
end

mio = MyIO.new(File.open("test.txt","wb+").fileno)
mio.write_stuff
mio.close
puts "Done"

Regards,

Dan

Hi all,

Windows XP Pro
Ruby 1.8.2

The following snippet dies on Windows with:

subtest.rb:8:in `write': not opened for writing (IOError)
from subtest.rb:8:in `write_stuff'
from subtest.rb:14

Works fine on *nix. Am I doing something wrong? Or is this a bug?

# subtest.rb
class MyIO < IO

  def initialize(arg)
     super(arg)
     binmode
  end

   def initialize *a, &b
     super *a
     binmode
     b and b.call
   end

  def write_stuff
     write("Hello World")
  end
end

mio = MyIO.new(File.open("test.txt","wb+").fileno)
mio.write_stuff
mio.close
puts "Done"

hth.

-a

···

On Thu, 13 Oct 2005, Berger, Daniel wrote:
--

email :: ara [dot] t [dot] howard [at] noaa [dot] gov
phone :: 303.497.6469
Your life dwells amoung the causes of death
Like a lamp standing in a strong breeze. --Nagarjuna

===============================================================================