diff --git a/base/iostream.jl b/base/iostream.jl index 30c8b65f9ea63..74908344e078e 100644 --- a/base/iostream.jl +++ b/base/iostream.jl @@ -228,16 +228,10 @@ function position(s::IOStream) end function filesize(s::IOStream) - sz = try - @_lock_ios s ccall(:ios_filesize, Int64, (Ptr{Cvoid},), s.ios) - catch e - e isa IOError || rethrow() - # if `s` is not seekable `ios_filesize` can fail, so fall back to slower stat method - filesize(stat(s)) - end + sz = @_lock_ios s ccall(:ios_filesize, Int64, (Ptr{Cvoid},), s.ios) if sz == -1 - err = Libc.errno() - throw(IOError(string("filesize: ", Libc.strerror(err), " for ", s.name), err)) + # if `s` is not seekable `ios_filesize` can fail, so fall back to slower stat method + sz = filesize(stat(s)) end return sz end