Skip to content

Commit

Permalink
fall back to slower stat filesize if optimized filesize fails (JuliaL…
Browse files Browse the repository at this point in the history
  • Loading branch information
IanButterworth committed Sep 24, 2024
1 parent 64cb0cd commit b5568fe
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions base/iostream.jl
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,8 @@ end
function filesize(s::IOStream)
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 b5568fe

Please sign in to comment.