Skip to content

Commit dbaba3c

Browse files
committed
std.fs.File.Reader: only fcopyfile if size available
1 parent 851436c commit dbaba3c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/std/fs/File.zig

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1825,6 +1825,7 @@ pub const Writer = struct {
18251825
if (file_reader.pos != 0) break :fcf;
18261826
if (w.pos != 0) break :fcf;
18271827
if (limit != .unlimited) break :fcf;
1828+
const size = file_reader.getSize() catch break :fcf;
18281829
const rc = std.c.fcopyfile(in_fd, out_fd, null, .{ .DATA = true });
18291830
switch (posix.errno(rc)) {
18301831
.SUCCESS => {},
@@ -1845,10 +1846,9 @@ pub const Writer = struct {
18451846
return 0;
18461847
},
18471848
}
1848-
const n = if (file_reader.size) |size| size else @panic("TODO figure out how much copied");
1849-
file_reader.pos = n;
1850-
w.pos = n;
1851-
return n;
1849+
file_reader.pos = size;
1850+
w.pos = size;
1851+
return size;
18521852
}
18531853

18541854
return error.Unimplemented;

0 commit comments

Comments
 (0)