Commit 9df37cbb authored by Alberto Ramos's avatar Alberto Ramos

Minor change in recording read position

parent 81b11657
......@@ -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,0,Int32(ifmt),Int8(iuinfo),hsh)
new = Record(false,long,Int64(0),ist,ist,Int32(ifmt),Int8(iuinfo),hsh)
push!(fb.records, new)
fb.ipt += 1
flush(fb.io)
......@@ -251,6 +251,7 @@ function BDIO_seek!(fb::BDIOstream, icnt::Int = 1)
end
if (ipt < length(fb.records))&&(ipt > 0)
fb.ipt = ipt
fb.rwpos = 0
return true
else
return false
......@@ -286,12 +287,12 @@ function BDIO_read(fb, vdata::Vector, n::Int64 = 0)
error("Data in record not available")
end
rpos::Int64 = max(fb.records[fb.ipt].rpos, fb.records[fb.ipt].rsav)
rpos::Int64 = max(fb.records[fb.ipt].rpos, fb.rwpos)
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)
fb.rwpos = position(fb.io)
end
......@@ -413,7 +414,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,0,hsh)
new = Record(true,false,rlen,rpos,rpos+rlen,0,0,hsh)
push!(fb.records, new)
seek(fb.io, rpos+rlen)
......@@ -429,7 +430,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,0,hsh)
new = Record(true,false,rlen,rpos,rpos+rlen,0,0,hsh)
else
islong = (mask = 1<<3; ihdr & mask == mask)
ifmt::Int32 = (ihdr & 0b11110000)>>>4
......@@ -442,7 +443,7 @@ function BDIO_parse!(fb::BDIOstream)
rpos = position(fb.io)
rlen = ihdr>>>12
end
new = Record(false,islong,rlen,rpos,rpos+rlen,0,Int32(ifmt),Int8(iuinfo),hsh)
new = Record(false,islong,rlen,rpos,rpos+rlen,Int32(ifmt),Int8(iuinfo),hsh)
end
push!(fb.records, new)
......@@ -493,7 +494,7 @@ function BDIO_write_header!(fb::BDIOstream)
flush(fb.io)
hsh = Nettle.Hasher("md5")
new = Record(true,false,Int64(ill),ist,ind,0,0,0,hsh)
new = Record(true,false,Int64(ill),ist,ind,0,0,hsh)
push!(fb.records, new)
fb.ipt += 1
......
......@@ -6,7 +6,6 @@ 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