X-Git-Url: http://git.code-monkey.de/?p=ruby-eet.git;a=blobdiff_plain;f=lib%2Feet.rb;h=8a949845063a5baf1ef8e0c75fa3ec7b9741dcfa;hp=ddac645d5404945b4a11379c30a2a35568aa7075;hb=49e6c8f56d89681f20836a14480959fa89d24e26;hpb=47d547c6a7bff822ae2cab01c81f50b7cc132b99 diff --git a/lib/eet.rb b/lib/eet.rb index ddac645..8a94984 100644 --- a/lib/eet.rb +++ b/lib/eet.rb @@ -1,5 +1,5 @@ #-- -# $Id: eet.rb 33 2005-04-30 11:10:16Z tilman $ +# $Id: eet.rb 34 2005-04-30 13:15:19Z tilman $ # # Copyright (c) 2005 Tilman Sauerbeck (tilman at code-monkey de) # @@ -166,10 +166,6 @@ module Eet super(chunk.nil? ? 0 : 1, chunk) end - def serialize - map { |c| c.serialize }.join - end - def Stream.deserialize(data) data = data.to_str.dup s = Stream.new @@ -194,21 +190,13 @@ module Eet @tag = tag.to_str.dup.freeze @data = data.to_str.dup.freeze - @size = @tag.length + 1 + @data.length - # libeet uses a signed 32bit integer to store the # chunk size, so make sure we don't overflow it - if @size >= (1 << 31) + if (@tag.length + 1 + @data.length) >= (1 << 31) raise(ArgumentError, "tag or data too long") end end - def serialize - buf = "CHnK" - buf << [@size].pack("V") - buf << @tag << "\0" << @data - end - def Chunk.deserialize(data) if data.length < 8 || data[0, 4] != "CHnK" raise(ChunkError, "invalid data")