| author | |
| committer | |
| log | d509bc933fe749cad270e11a7f3be88e1ec9a1a7 |
| tree | cd8635a5b78b14eeca95750d467a8a4f883ea72b |
| parent | f34b4780b7bd52d14df253d0762d9c73db8eb226 |
it shan't be missed2 files changed, 0 insertions(+), 48 deletions(-)
lib/std/Io.zig-4| ... | @@ -448,9 +448,6 @@ pub const bufferedReaderSize = @import("Io/buffered_reader.zig").bufferedReaderS | ... | @@ -448,9 +448,6 @@ pub const bufferedReaderSize = @import("Io/buffered_reader.zig").bufferedReaderS |
| 448 | pub const FixedBufferStream = @import("Io/fixed_buffer_stream.zig").FixedBufferStream; | 448 | pub const FixedBufferStream = @import("Io/fixed_buffer_stream.zig").FixedBufferStream; |
| 449 | pub const fixedBufferStream = @import("Io/fixed_buffer_stream.zig").fixedBufferStream; | 449 | pub const fixedBufferStream = @import("Io/fixed_buffer_stream.zig").fixedBufferStream; |
| 450 | 450 | ||
| 451 | pub const CWriter = @import("Io/c_writer.zig").CWriter; | ||
| 452 | pub const cWriter = @import("Io/c_writer.zig").cWriter; | ||
| 453 | |||
| 454 | pub const LimitedReader = @import("Io/limited_reader.zig").LimitedReader; | 451 | pub const LimitedReader = @import("Io/limited_reader.zig").LimitedReader; |
| 455 | pub const limitedReader = @import("Io/limited_reader.zig").limitedReader; | 452 | pub const limitedReader = @import("Io/limited_reader.zig").limitedReader; |
| 456 | 453 | ||
| ... | @@ -903,7 +900,6 @@ test { | ... | @@ -903,7 +900,6 @@ test { |
| 903 | _ = @import("Io/buffered_atomic_file.zig"); | 900 | _ = @import("Io/buffered_atomic_file.zig"); |
| 904 | _ = @import("Io/buffered_reader.zig"); | 901 | _ = @import("Io/buffered_reader.zig"); |
| 905 | _ = @import("Io/buffered_writer.zig"); | 902 | _ = @import("Io/buffered_writer.zig"); |
| 906 | _ = @import("Io/c_writer.zig"); | ||
| 907 | _ = @import("Io/counting_writer.zig"); | 903 | _ = @import("Io/counting_writer.zig"); |
| 908 | _ = @import("Io/counting_reader.zig"); | 904 | _ = @import("Io/counting_reader.zig"); |
| 909 | _ = @import("Io/fixed_buffer_stream.zig"); | 905 | _ = @import("Io/fixed_buffer_stream.zig"); |
lib/std/Io/c_writer.zig deleted-44| ... | @@ -1,44 +0,0 @@ | ||
| 1 | const std = @import("../std.zig"); | ||
| 2 | const builtin = @import("builtin"); | ||
| 3 | const io = std.io; | ||
| 4 | const testing = std.testing; | ||
| 5 | |||
| 6 | pub const CWriter = io.GenericWriter(*std.c.FILE, std.fs.File.WriteError, cWriterWrite); | ||
| 7 | |||
| 8 | pub fn cWriter(c_file: *std.c.FILE) CWriter { | ||
| 9 | return .{ .context = c_file }; | ||
| 10 | } | ||
| 11 | |||
| 12 | fn cWriterWrite(c_file: *std.c.FILE, bytes: []const u8) std.fs.File.WriteError!usize { | ||
| 13 | const amt_written = std.c.fwrite(bytes.ptr, 1, bytes.len, c_file); | ||
| 14 | if (amt_written >= 0) return amt_written; | ||
| 15 | switch (@as(std.c.E, @enumFromInt(std.c._errno().*))) { | ||
| 16 | .SUCCESS => unreachable, | ||
| 17 | .INVAL => unreachable, | ||
| 18 | .FAULT => unreachable, | ||
| 19 | .AGAIN => unreachable, // this is a blocking API | ||
| 20 | .BADF => unreachable, // always a race condition | ||
| 21 | .DESTADDRREQ => unreachable, // connect was never called | ||
| 22 | .DQUOT => return error.DiskQuota, | ||
| 23 | .FBIG => return error.FileTooBig, | ||
| 24 | .IO => return error.InputOutput, | ||
| 25 | .NOSPC => return error.NoSpaceLeft, | ||
| 26 | .PERM => return error.PermissionDenied, | ||
| 27 | .PIPE => return error.BrokenPipe, | ||
| 28 | else => |err| return std.posix.unexpectedErrno(err), | ||
| 29 | } | ||
| 30 | } | ||
| 31 | |||
| 32 | test cWriter { | ||
| 33 | if (!builtin.link_libc or builtin.os.tag == .wasi) return error.SkipZigTest; | ||
| 34 | |||
| 35 | const filename = "tmp_io_test_file.txt"; | ||
| 36 | const out_file = std.c.fopen(filename, "w") orelse return error.UnableToOpenTestFile; | ||
| 37 | defer { | ||
| 38 | _ = std.c.fclose(out_file); | ||
| 39 | std.fs.cwd().deleteFileZ(filename) catch {}; | ||
| 40 | } | ||
| 41 | |||
| 42 | const writer = cWriter(out_file); | ||
| 43 | try writer.print("hi: {}\n", .{@as(i32, 123)}); | ||
| 44 | } | ||