Commit f632e103 authored by Alberto Ramos's avatar Alberto Ramos

Add routine to read a nul-terminated string

parent 51191c7a
......@@ -316,6 +316,32 @@ function BDIO_read(fb::BDIOstream, vdata::Vector, n::Int64 = 0)
end
"""
BDIO_read_str(fb::BDIOstream)
Read a nul-terminated string from BDIO file.
## Arguments
- `fb`: A BDIOstream type. It must be associated with a file.
## Examples
```julia-repl
julia> # Real 1000 floats from the first record of file `randoms.bdio`
julia> fb = BDIO_open("randoms.bdio", "r")
julia> BDIO_seek!(fb)
julia> str = BDIO_read_str(fb)
```
"""
function BDIO_read_str(fb::BDIOstream)
rpos::Int64 = max(fb.records[fb.ipt].rpos, fb.rwpos)
seek(fb.io,rpos)
str::String = readuntil(fb.io, '\0')
fb.rwpos = position(fb.io)
return str
end
"""
BDIO_get_len(fb::BDIOstream)
......
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