Skip to content

Commit

Permalink
Update iostream.jl
Browse files Browse the repository at this point in the history
Co-authored-by: Jameson Nash <[email protected]>
  • Loading branch information
IanButterworth and vtjnash authored Aug 31, 2024
1 parent 0d691e5 commit 984f884
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions base/iostream.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 984f884

Please sign in to comment.