Commit ed653c27 authored by Alberto Ramos's avatar Alberto Ramos

Bug in BDIO_read

parent e8eec401
......@@ -149,7 +149,7 @@ function BDIO_start_record!(fb::BDIOstream, ifmt, iuinfo, long::Bool = false)
ist::Int64 = position(fb.io)
hsh = Nettle.Hasher("md5")
new = Record(false,long,Int64(0),ist,ist,Int32(ifmt),Int8(iuinfo),hsh)
new = Record(false,long,Int64(0),ist,ist,0,Int32(ifmt),Int8(iuinfo),hsh)
push!(fb.records, new)
fb.ipt += 1
flush(fb.io)
......@@ -285,11 +285,14 @@ function BDIO_read(fb, vdata::Vector, n::Int64 = 0)
if (nmax*sizeof(vdata[1]) > fb.records[fb.ipt].rlen)
error("Data in record not available")
end
seek(fb.io,fb.records[fb.ipt].rpos)
rpos::Int64 = max(fb.records[fb.ipt].rpos, fb.records[fb.ipt].rsav)
seek(fb.io,rpos)
for i = 1:nmax
vdata[i] = read(fb.io, typeof(vdata[1]))
end
fb.records[fb.ipt].rsav = position(fb.io)
end
"""
......@@ -410,7 +413,7 @@ function BDIO_parse!(fb::BDIOstream)
if (ihdr!=BDIO_MAGIC)
error("Not a BDIO file")
end
new = Record(true,false,rlen,rpos,rpos+rlen,0,0,hsh)
new = Record(true,false,rlen,rpos,rpos+rlen,0,0,0,hsh)
push!(fb.records, new)
seek(fb.io, rpos+rlen)
......@@ -426,7 +429,7 @@ function BDIO_parse!(fb::BDIOstream)
i32::Int32 = read(fb.io, Int32)
rlen = Int64(i32 & 0b111111111111)
rpos = position(fb.io)
new = Record(true,false,rlen,rpos,rpos+rlen,0,0,hsh)
new = Record(true,false,rlen,rpos,rpos+rlen,0,0,0,hsh)
else
islong = (mask = 1<<3; ihdr & mask == mask)
ifmt::Int32 = (ihdr & 0b11110000)>>>4
......@@ -439,7 +442,7 @@ function BDIO_parse!(fb::BDIOstream)
rpos = position(fb.io)
rlen = ihdr>>>12
end
new = Record(false,islong,rlen,rpos,rpos+rlen,Int32(ifmt),Int8(iuinfo),hsh)
new = Record(false,islong,rlen,rpos,rpos+rlen,0,Int32(ifmt),Int8(iuinfo),hsh)
end
push!(fb.records, new)
......@@ -490,7 +493,7 @@ function BDIO_write_header!(fb::BDIOstream)
flush(fb.io)
hsh = Nettle.Hasher("md5")
new = Record(true,false,Int64(ill),ist,ind,0,0,hsh)
new = Record(true,false,Int64(ill),ist,ind,0,0,0,hsh)
push!(fb.records, new)
fb.ipt += 1
......
......@@ -6,7 +6,8 @@ mutable struct Record
rlen::Int64
rpos::Int64
rend::Int64
rsav::Int64
rfmt::Int32
ruinfo::Int8
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment