Skip to content

Commit 97a6258

Browse files
authored
fix error thrown by filesize(::IOStream) (#35984)
1 parent dd1e54d commit 97a6258

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

base/iostream.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,10 @@ end
221221

222222
function filesize(s::IOStream)
223223
sz = @_lock_ios s ccall(:ios_filesize, Int64, (Ptr{Cvoid},), s.ios)
224-
systemerror("filesize", sz == -1)
224+
if sz == -1
225+
err = Libc.errno()
226+
throw(IOError(string("filesize: ", Libc.strerror(err), " for ", s.name), err))
227+
end
225228
return sz
226229
end
227230

src/support/ios.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -548,8 +548,6 @@ int64_t ios_pos(ios_t *s)
548548

549549
int64_t ios_filesize(ios_t *s)
550550
{
551-
if (s->fd == -1)
552-
return -1;
553551
int64_t fdpos = s->fpos;
554552
if (fdpos == (int64_t)-1) {
555553
fdpos = lseek(s->fd, 0, SEEK_CUR);

0 commit comments

Comments
 (0)