authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-07-20 20:46:07-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-07-21 12:32:37-07:00
logfe10c66d664ae7b1acb2bcf01600eeacc2958fc7
tree0419f39533d6564c5b2737f1d5c55e5bb3d49f4f
parent38559e282b137ea365ab074e3d78cf3312dd5702

std.fs.File.Reader: only fcopyfile if size available


1 files changed, 4 insertions(+), 4 deletions(-)

lib/std/fs/File.zig+4-4
...@@ -1825,6 +1825,7 @@ pub const Writer = struct {...@@ -1825,6 +1825,7 @@ pub const Writer = struct {
1825 if (file_reader.pos != 0) break :fcf;1825 if (file_reader.pos != 0) break :fcf;
1826 if (w.pos != 0) break :fcf;1826 if (w.pos != 0) break :fcf;
1827 if (limit != .unlimited) break :fcf;1827 if (limit != .unlimited) break :fcf;
1828 const size = file_reader.getSize() catch break :fcf;
1828 const rc = std.c.fcopyfile(in_fd, out_fd, null, .{ .DATA = true });1829 const rc = std.c.fcopyfile(in_fd, out_fd, null, .{ .DATA = true });
1829 switch (posix.errno(rc)) {1830 switch (posix.errno(rc)) {
1830 .SUCCESS => {},1831 .SUCCESS => {},
...@@ -1845,10 +1846,9 @@ pub const Writer = struct {...@@ -1845,10 +1846,9 @@ pub const Writer = struct {
1845 return 0;1846 return 0;
1846 },1847 },
1847 }1848 }
1848 const n = if (file_reader.size) |size| size else @panic("TODO figure out how much copied");1849 file_reader.pos = size;
1849 file_reader.pos = n;1850 w.pos = size;
1850 w.pos = n;1851 return size;
1851 return n;
1852 }1852 }
18531853
1854 return error.Unimplemented;1854 return error.Unimplemented;