Skip to content

Commit d2e5c8f

Browse files
IanButterworthKristofferC
authored andcommitted
fall back to slower stat filesize if optimized filesize fails (#55641)
(cherry picked from commit fc9f147)
1 parent c5caf18 commit d2e5c8f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

base/iostream.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,8 @@ end
222222
function filesize(s::IOStream)
223223
sz = @_lock_ios s ccall(:ios_filesize, Int64, (Ptr{Cvoid},), s.ios)
224224
if sz == -1
225-
err = Libc.errno()
226-
throw(IOError(string("filesize: ", Libc.strerror(err), " for ", s.name), err))
225+
# if `s` is not seekable `ios_filesize` can fail, so fall back to slower stat method
226+
sz = filesize(stat(s))
227227
end
228228
return sz
229229
end

0 commit comments

Comments
 (0)