Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > reading binary data stops unexpectedly

Reply
Thread Tools

reading binary data stops unexpectedly

 
 
Gonzalo Rubio
Guest
Posts: n/a
 
      03-05-2006
i'm trying to parse a binary file that simply contains Wav files one
after the other packed with an arbitrary header that points where one
file begins and the lenght of it.
The case is that i want to ignore decomposing the header and just dump
each file as i encounter the Wav headers, but Ruby stops reading data
unexpectedly.

in a nutshell, my code goes like this:
File.open('sound.dat', 'r').each_byte do |byte|
#...stuff to process the data...
end

The block exits at 15864 bytes without throwing any errors. I even tried
reading the whole file to memory and it just loads those same 15864
bytes (and it's a 190MiB file!!!)

Is this a known Ruby bug? am i doing something wrong?

thanks in advance,
/gonchuki

--
Posted via http://www.ruby-forum.com/.


 
Reply With Quote
 
 
 
 
Marcin Mielżyński
Guest
Posts: n/a
 
      03-05-2006
Gonzalo Rubio wrote:

> in a nutshell, my code goes like this:
> File.open('sound.dat', 'r').each_byte do |byte|
> #...stuff to process the data...
> end


open('sound.dat', 'rb')


lopex
 
Reply With Quote
 
 
 
 
Gonzalo Rubio
Guest
Posts: n/a
 
      03-05-2006
Marcin Mielżyński wrote:
> Gonzalo Rubio wrote:
>
>> in a nutshell, my code goes like this:
>> File.open('sound.dat', 'r').each_byte do |byte|
>> #...stuff to process the data...
>> end

>
> open('sound.dat', 'rb')
>
>
> lopex


nice!

i just couldn't find it in the pickaxe 2 and forgot that ruby handles
file open modes just like in C

thanks for your help.

--
Posted via http://www.ruby-forum.com/.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Java Web Start Console closes unexpectedly / Reading in data ChrisC Java 11 02-07-2007 05:19 AM
SQLDataReader stops responding after reading. elitehunter99 ASP .Net 0 10-17-2006 01:03 PM
pyserial problem: script stops reading Frederic Wenzel Python 0 09-09-2006 01:25 AM
pyserial problem: script stops reading Frederic Wenzel Python 0 09-09-2006 01:24 AM
Advice needed: reading image (binary) data from a db, to be placed in an Image control ?? Denise Smith ASP .Net 2 11-22-2003 02:18 PM



Advertisments