The following seems to work.
I have created a module Uff.jl
:
module Uff
using FileIO
struct UFFReader
io::IO
ownstream::Bool
end
function Base.read( reader::UFFReader )
# read and decode audio samples from reader.io
readline(reader.io)
end
function Base.close(reader::UFFReader)
# do whatever cleanup the reader needs
reader.ownstream && close(reader.io)
end
Base.eof(reader::UFFReader) = eof( reader.io )
loadstreaming(f::File{format"UFF"}) = UFFReader(open(f.filename), true)
loadstreaming(s::Stream{format"UFF"}) = UFFReader(s, false)
end
Just for the record it seems to work when I do:
using FileIO
using Uff
add_format(format"UFF", (), [".uff",".unv"], [:Uff])
loadstreaming("example.unv") do io
while !eof(io)
print(read(io))
end
end
So it is a matter of replacing readline(reader.io)
for whatever parser needs to be used and replacing print(read(io))
for whatever processing we want to do in the future.
I will keep posting improvements as I learn them. (Just for the record)