Skip to content

Commit

Permalink
fall back to slower stat filesize if optimized filesize fails (#55641)
Browse files Browse the repository at this point in the history
(cherry picked from commit fc9f147)
  • Loading branch information
IanButterworth authored and KristofferC committed Sep 24, 2024
1 parent 1d51535 commit 47e8cab
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 @@ -224,8 +224,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 47e8cab

Please sign in to comment.