Issue #6179 has been updated by jmthomas (Jason Thomas).
This is an issue on 1.9.3p125 on Windows and doesn't just affect binary mode. Try the following program:
# This example shows File#pos moving the file position with Ruby 1.9.3p125 on Windows
File.open("test.txt", "w") {|file| file.write("Jason says\nThat Ruby shouldn't\nbe broken\n")}
def test_read (call_pos)
lines = ["Jason says\n", "That Ruby shouldn't\n", "be broken\n"]
File.open("test.txt", "r") do |file|
lines.each do |line|
file.pos if call_pos # Moves file position on Ruby 1.9.3p125 on Windows
read_line = file.readline
puts read_line
raise "Error!" if line != read_line
end
end
end
# Works
test_read(false)
puts
# Fails
test_read(true)
----------------------------------------
Bug #6179: File::pos broken in Windows 1.9.3p125
https://bugs.ruby-lang.org/issues/6179#change-25009
Author: jmthomas (Jason Thomas)
Status: Closed
Priority: Normal
Assignee:
Category: core
Target version: 1.9.3
ruby -v: 1.9.3p125
Calling the pos method on a File in the Windows version of Ruby on 1.9.3p125 moves the file pointer. Thus it can not be called without side effect.
--
http://bugs.ruby-lang.org/