Alan Davies
11/18/2003 5:10:00 PM
On the cygwin build of ruby v1.8.0, I have encountered a strange bug
when using rewind, syswrite and pos. If you open a file in read/write
mode, read the contents, rewind, syswrite some data, then File#pos
always seems to return zero. This does not happen if you use the
windows build, or you replace 'syswrite' with 'write'.
e.g:
$ cat syswrite.rb
#!/bin/ruby
testStr = "hello\nthis is some example text\nblah blah blah"
# read it, rewind, then write it back again
File.open("out.txt", 'r+') do |file|
file.readlines
file.rewind
bytes = file.syswrite(testStr)
puts "#{bytes} bytes written"
puts "Now at position #{file.pos}"
end
$ ls > out.txt
$ syswrite.rb
46 bytes written
Now at position 0