Project

General

Profile

Bug #1052 ยป file_seek_pos_issue.rb

Small example for reproducing problem with seek, readpartial and pos. - MenThal (Kent Dahl), 01/26/2009 06:17 PM

 
1
filename = "/tmp/foobar.tmp"
2

    
3
File.open(filename, 'w'){|f|
4
  10.times {|i| f.puts "#{i} bottles of beer..." }
5
}
6

    
7
File.open(filename){|f|
8
  f.seek 0  # Comment out this, and it works.
9
  f.readpartial(10)
10
  p f.pos # Expect 10, not 0.
11
}
12

    
13
# Output:
14
# ruby1.8 tmp/file_seek_pos_issue.rb => 0
15
# ruby1.9 tmp/file_seek_pos_issue.rb => 10
16

    
17
# System:
18
# - ruby 1.8.7 (2008-08-11 patchlevel 72) [i486-linux]
19
# - ruby 1.9.0 (2008-06-20 revision 17482) [i486-linux]
20
# Ubuntu 8.10
21
# - Linux wintermute 2.6.27-7-generic #1 SMP Tue Nov 4 19:33:20 UTC 2008 i686 GNU/Linux