Problem subclassing IO and writing on Windows

B

Berger, Daniel

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) =20
super(arg)
binmode =20
end
=20
def write_stuff
write("Hello World")
end
end

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

Regards,

Dan
 
A

Ara.T.Howard

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
--
===============================================================================
| 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
===============================================================================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,153
Members
46,699
Latest member
AnneRosen

Latest Threads

Top