Commit 3923ce63 authored by Alberto Ramos's avatar Alberto Ramos

Added missing private functions

parent 0a420bb6
...@@ -423,3 +423,91 @@ function BDIO_parse!(fb::BDIOstream) ...@@ -423,3 +423,91 @@ function BDIO_parse!(fb::BDIOstream)
end end
function BDIO_write_header!(fb::BDIOstream)
if (fb.imode == BDIO_R_MODE)
error("Attemp to write in READ mode")
end
ihdr::Int32 = BDIO_MAGIC
write(fb.io, ihdr)
mark(fb.io)
ill::Int16 = 0
write(fb.io, ill)
iv::Int16 = 1
write(fb.io, iv)
ist::Int64 = position(fb.io)
i4::Int32 = 0
write(fb.io, i4)
hcr::Int64 = position(fb.io)
write(fb.io, fb.created)
fb.rdate = position(fb.io)
write(fb.io, fb.modified)
write(fb.io, user*"\0")
hlu::Int64 = position(fb.io)
write(fb.io, user*"\0")
write(fb.io, host*"\0")
hlh::Int64 = position(fb.io)
write(fb.io, host*"\0")
write(fb.io, fb.info*"\0")
ind::Int64 = position(fb.io)
ill = Int16(ind-ist)
reset(fb.io)
write(fb.io, ill)
flush(fb.io)
hsh = Nettle.Hasher("md5")
new = Record(true,false,Int64(ill),ist,ind,0,0,hsh)
push!(fb.records, new)
fb.ipt += 1
return true
end
function BDIOstream(fname::String, mode::String, protocol_info::String="\0")
md::Int32 = 0
if (mode == "w")
if (isfile(fname))
error("File "*strip(fname)*" already exists")
end
io = open(fname, "w+")
md = BDIO_W_MODE
elseif (mode == "r")
io = open(fname, "r")
md = BDIO_R_MODE
elseif (mode == "a")
io = open(fname, "a+")
md = BDIO_A_MODE
elseif (mode == "d")
rm(fnme, force=true)
io = open(fname, "w+")
md = BDIO_D_MODE
else
error("Incorrect mode")
end
rcs = similar(Array{Record,1},0)
lend::Bool = true
if (Base.ENDIAN_BOM == 0x04030201)
lend = true
elseif (Base.ENDIAN_BOM == 0x01020304)
lend = false
else
error("Wrong endianness")
end
if (!lend)
error("Current version only support Little Endian Machines")
end
return BDIOstream(io,1,md,0,0,lend,user,host,
floor(Int32, time()), floor(Int32, time()), protocol_info, 0, rcs)
end
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