Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/io/bufferedio.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ Base.show(io::IO, ::BufferedReader) = print(io, "BufferedReader")

function readmore!(io::BufferedReader, n::Integer)
f = io.f
amount = max(bytesavailable(f), n) #TODO: check if this reads way to much
sz = _getsize(f)
amount = min(max(n, 2^14), sz-position(f))
amount < n && throw(EOFError())
buffer = io.buffer
pos = bufferpos(io)
Expand Down
17 changes: 7 additions & 10 deletions src/io/io_wrappers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -172,17 +172,14 @@ Base.isreadable(::RWBuffer) = true
Base.iswritable(::RWBuffer) = true
isseekable(::RWBuffer) = true

_getsize(io::RWBuffer) = io.size

function _getsize(io::IO)
try
return filesize(io)
catch
# fallback
pos = position(io)
seekend(io)
sz = position(io)
seek(io, pos)
return sz
end
pos = position(io)
seekend(io)
sz = position(io)
seek(io, pos)
return sz
end

###########################################################################################
Expand Down
Loading