| author | |
| committer | |
| log | faab6d5cbf18d25628793994e080f79d95adf4ea |
| tree | bb83b6a060c5a3113c671915411a257ebfa6ae44 |
| parent | 1501734747afb60c6b28adb0da1e49ff46a31f17 |
5 files changed, 18 insertions(+), 8 deletions(-)
lib/std/fs/File.zig+9-2| ... | ... | @@ -1737,7 +1737,8 @@ pub fn writer_writeFile( |
| 1737 | 1737 | const smaller_len = if (len_int == 0) max_count else @min(len_int, max_count); |
| 1738 | 1738 | var off: std.os.linux.off_t = undefined; |
| 1739 | 1739 | const off_ptr: ?*std.os.linux.off_t = if (in_offset.toInt()) |offset| b: { |
| 1740 | off = std.math.cast(std.os.linux.off_t, offset) orelse return error.Overflow; | |
| 1740 | off = std.math.cast(std.os.linux.off_t, offset) orelse | |
| 1741 | return writer_writeSplat(context, headers_and_trailers, 1); | |
| 1741 | 1742 | break :b &off; |
| 1742 | 1743 | } else null; |
| 1743 | 1744 | if (true) @panic("TODO"); |
| ... | ... | @@ -1747,7 +1748,13 @@ pub fn writer_writeFile( |
| 1747 | 1748 | error.Unexpected => break :sf, |
| 1748 | 1749 | else => |e| return e, |
| 1749 | 1750 | }; |
| 1750 | if (in_offset.toInt()) |offset| assert(n == off - offset); | |
| 1751 | if (in_offset.toInt()) |offset| { | |
| 1752 | assert(n == off - offset); | |
| 1753 | } else if (n == 0 and len_int == 0) { | |
| 1754 | // The caller wouldn't be able to tell that the file transfer is | |
| 1755 | // done and would incorrectly repeat the same call. | |
| 1756 | return writer_writeSplat(context, headers_and_trailers, 1); | |
| 1757 | } | |
| 1751 | 1758 | return n; |
| 1752 | 1759 | } |
| 1753 | 1760 | var iovecs_buffer: [max_buffers_len]std.posix.iovec_const = undefined; |
lib/std/io/BufferedWriter.zig+2-1| ... | ... | @@ -69,7 +69,8 @@ pub fn reset(bw: *BufferedWriter) void { |
| 69 | 69 | pub fn flush(bw: *BufferedWriter) anyerror!void { |
| 70 | 70 | const list = &bw.buffer; |
| 71 | 71 | const send_buffer = list.items; |
| 72 | try bw.unbuffered_writer.writeAll(send_buffer); | |
| 72 | var index: usize = 0; | |
| 73 | while (index < send_buffer.len) index += try bw.unbuffered_writer.writev(&.{send_buffer[index..]}); | |
| 73 | 74 | list.items.len = 0; |
| 74 | 75 | } |
| 75 | 76 |
lib/std/io/Writer.zig+3| ... | ... | @@ -149,6 +149,9 @@ fn null_writeFile( |
| 149 | 149 | ) anyerror!usize { |
| 150 | 150 | _ = context; |
| 151 | 151 | var n: usize = 0; |
| 152 | if (offset == .none) { | |
| 153 | @panic("TODO seek the file forwards"); | |
| 154 | } | |
| 152 | 155 | if (len == .entire_file) { |
| 153 | 156 | const headers = headers_and_trailers[0..headers_len]; |
| 154 | 157 | for (headers) |bytes| n += bytes.len; |
lib/std/posix.zig+3-4| ... | ... | @@ -6359,7 +6359,7 @@ pub const SendFileError = PReadError || WriteError || SendError; |
| 6359 | 6359 | pub fn sendfile( |
| 6360 | 6360 | out_fd: fd_t, |
| 6361 | 6361 | in_fd: fd_t, |
| 6362 | in_offset: ?u64, | |
| 6362 | in_offset: u64, | |
| 6363 | 6363 | in_len: u64, |
| 6364 | 6364 | headers: []const iovec_const, |
| 6365 | 6365 | trailers: []const iovec_const, |
| ... | ... | @@ -6390,9 +6390,8 @@ pub fn sendfile( |
| 6390 | 6390 | |
| 6391 | 6391 | const sendfile_sym = if (lfs64_abi) system.sendfile64 else system.sendfile; |
| 6392 | 6392 | while (true) { |
| 6393 | var offset: off_t = if (in_offset) |o| o else undefined; | |
| 6394 | const offset_pointer: ?*off_t = if (in_offset) &offset else null; | |
| 6395 | const rc = sendfile_sym(out_fd, in_fd, offset_pointer, adjusted_count); | |
| 6393 | var offset: off_t = @bitCast(in_offset); | |
| 6394 | const rc = sendfile_sym(out_fd, in_fd, &offset, adjusted_count); | |
| 6396 | 6395 | switch (errno(rc)) { |
| 6397 | 6396 | .SUCCESS => { |
| 6398 | 6397 | const amt: usize = @bitCast(rc); |
test/standalone/simple/hello_world/hello.zig+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | 2 | |
| 3 | 3 | pub fn main() !void { |
| 4 | try std.io.getStdOut().writeAll("Hello, World!\n"); | |
| 4 | try std.fs.File.stdout().writeAll("Hello, World!\n"); | |
| 5 | 5 | } |