J
Jay Daniels
I got a question that's puzzling me. Am new to Ruby but programming for
decades. Here's the problem. This apparently simple loop reads 396 bytes
of a file and no more. The actual file is 1.5KB and I can display it
easily in a hex dumper. The bytes Ruby has read are all correct. It just
seems to stop after 396 bytes. Any idea what's wrong or where I should
be looking?
Many thanks in advance,
JK Daniels
if ARGV[0] == nil
puts( "\n" + $help )
else
i = 0
tfm = File.open( ARGV[0] )
tfm.each_byte{ |c| i = i + 1; printf( "%d: %X\n", i, c ) }
if tfm.eof
puts "at eof" else puts "not at eof"
end
end
<<< end code <<<
This outputs the first 396 bytes and then state it's at EOF. If it makes
any difference, the last three bytes it reads are (all hex): C0 A4 00
and the next three (unread) bytes in the file are: 1A C0 B5
decades. Here's the problem. This apparently simple loop reads 396 bytes
of a file and no more. The actual file is 1.5KB and I can display it
easily in a hex dumper. The bytes Ruby has read are all correct. It just
seems to stop after 396 bytes. Any idea what's wrong or where I should
be looking?
Many thanks in advance,
JK Daniels
if ARGV[0] == nil
puts( "\n" + $help )
else
i = 0
tfm = File.open( ARGV[0] )
tfm.each_byte{ |c| i = i + 1; printf( "%d: %X\n", i, c ) }
if tfm.eof
puts "at eof" else puts "not at eof"
end
end
<<< end code <<<
This outputs the first 396 bytes and then state it's at EOF. If it makes
any difference, the last three bytes it reads are (all hex): C0 A4 00
and the next three (unread) bytes in the file are: 1A C0 B5