> -----Original Message-----
> From: Ara.T.Howard [mailto:Ara.T.Howard / noaa.gov] 
> Sent: Wednesday, October 12, 2005 2:26 PM
> To: ruby-talk ML
> Subject: Re: Problem subclassing IO and writing on Windows

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

That's not it.  I didn't see that you have to pass the mode *twice* on
Windows:

# This works:
io = IO.new(File.open("test.txt", "wb+").fileno, "wb+")
io.write("hello")
io.close

# This fails:
io = IO.new(File.open("test.txt").fileno, "wb+")
io.write("hello")
io.close

iotest.rb:3:in `close': Bad file descriptor (Errno::EBADF)
        from iotest.rb:3

# This also fails:
io = IO.new(File.open("test.txt", "wb+").fileno)
io.write("hello")
io.close

C:\eclipse\workspace\ruby-foo\iostuff>ruby iotest.rb
iotest.rb:2:in `write': not opened for writing (IOError)
        from iotest.rb:2

I'll have to look at io.c now to see what's really going on.  At least
it works now. :)

Regards,

Dan