Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
reading binary data stops unexpectedly
Gonzalo Rubio
3/5/2006 2:24:00 PM
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-...
.
2 Answers
Marcin Mielzynski
3/5/2006 2:32:00 PM
0
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
Gonzalo Rubio
3/5/2006 3:24:00 PM
0
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-...
.
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
reading binary data stops unexpectedly
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password