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
  • Loading branch information
IanButterworth authored Sep 23, 2024
1 parent 0fade45 commit fc9f147
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 fc9f147

Please sign in to comment.