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) ...@@ -149,7 +149,7 @@ function BDIO_start_record!(fb::BDIOstream, ifmt, iuinfo, long::Bool = false)
ist::Int64 = position(fb.io) ist::Int64 = position(fb.io)
hsh = Nettle.Hasher("md5") 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) push!(fb.records, new)
fb.ipt += 1 fb.ipt += 1
flush(fb.io) flush(fb.io)
...@@ -251,6 +251,7 @@ function BDIO_seek!(fb::BDIOstream, icnt::Int = 1) ...@@ -251,6 +251,7 @@ function BDIO_seek!(fb::BDIOstream, icnt::Int = 1)
end end
if (ipt < length(fb.records))&&(ipt > 0) if (ipt < length(fb.records))&&(ipt > 0)
fb.ipt = ipt fb.ipt = ipt
fb.rwpos = 0
return true return true
else else
return false return false
...@@ -286,12 +287,12 @@ function BDIO_read(fb, vdata::Vector, n::Int64 = 0) ...@@ -286,12 +287,12 @@ function BDIO_read(fb, vdata::Vector, n::Int64 = 0)
error("Data in record not available") error("Data in record not available")
end 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) seek(fb.io,rpos)
for i = 1:nmax for i = 1:nmax
vdata[i] = read(fb.io, typeof(vdata[1])) vdata[i] = read(fb.io, typeof(vdata[1]))
end end
fb.records[fb.ipt].rsav = position(fb.io) fb.rwpos = position(fb.io)
end end
...@@ -413,7 +414,7 @@ function BDIO_parse!(fb::BDIOstream) ...@@ -413,7 +414,7 @@ function BDIO_parse!(fb::BDIOstream)
if (ihdr!=BDIO_MAGIC) if (ihdr!=BDIO_MAGIC)
error("Not a BDIO file") error("Not a BDIO file")
end 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) push!(fb.records, new)
seek(fb.io, rpos+rlen) seek(fb.io, rpos+rlen)
...@@ -429,7 +430,7 @@ function BDIO_parse!(fb::BDIOstream) ...@@ -429,7 +430,7 @@ function BDIO_parse!(fb::BDIOstream)
i32::Int32 = read(fb.io, Int32) i32::Int32 = read(fb.io, Int32)
rlen = Int64(i32 & 0b111111111111) rlen = Int64(i32 & 0b111111111111)
rpos = position(fb.io) 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 else
islong = (mask = 1<<3; ihdr & mask == mask) islong = (mask = 1<<3; ihdr & mask == mask)
ifmt::Int32 = (ihdr & 0b11110000)>>>4 ifmt::Int32 = (ihdr & 0b11110000)>>>4
...@@ -442,7 +443,7 @@ function BDIO_parse!(fb::BDIOstream) ...@@ -442,7 +443,7 @@ function BDIO_parse!(fb::BDIOstream)
rpos = position(fb.io) rpos = position(fb.io)
rlen = ihdr>>>12 rlen = ihdr>>>12
end 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 end
push!(fb.records, new) push!(fb.records, new)
...@@ -493,7 +494,7 @@ function BDIO_write_header!(fb::BDIOstream) ...@@ -493,7 +494,7 @@ function BDIO_write_header!(fb::BDIOstream)
flush(fb.io) flush(fb.io)
hsh = Nettle.Hasher("md5") 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) push!(fb.records, new)
fb.ipt += 1 fb.ipt += 1
......
...@@ -6,7 +6,6 @@ mutable struct Record ...@@ -6,7 +6,6 @@ mutable struct Record
rlen::Int64 rlen::Int64
rpos::Int64 rpos::Int64
rend::Int64 rend::Int64
rsav::Int64
rfmt::Int32 rfmt::Int32
ruinfo::Int8 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