| ... | ... | @@ -7,27 +7,32 @@ pub const File = @import("./File.zig"); |
| 7 | 7 | |
| 8 | 8 | const os = builtin.target.os.tag; |
| 9 | 9 | |
| 10 | const sys = switch (os) { |
| 11 | .linux => sys_linux, |
| 12 | else => unreachable, |
| 13 | }; |
| 14 | |
| 10 | 15 | pub const Handle = switch (os) { |
| 11 | 16 | .linux => enum(c_int) { _ }, |
| 12 | | else => @compileError("TODO"), |
| 17 | else => unreachable, |
| 13 | 18 | }; |
| 14 | 19 | |
| 15 | 20 | pub fn cwd() Dir { |
| 16 | | if (os == .linux) |
| 17 | | return .{ .fd = @enumFromInt(sys_linux.AT.FDCWD) }; |
| 21 | return .{ .fd = @enumFromInt(sys.AT.FDCWD) }; |
| 18 | 22 | } |
| 19 | 23 | |
| 20 | 24 | pub fn stdin() File { |
| 21 | | if (os == .linux) |
| 22 | | return .{ .fd = @enumFromInt(0) }; |
| 25 | return .{ .fd = @enumFromInt(0) }; |
| 23 | 26 | } |
| 24 | 27 | |
| 25 | 28 | pub fn stdout() File { |
| 26 | | if (os == .linux) |
| 27 | | return .{ .fd = @enumFromInt(1) }; |
| 29 | return .{ .fd = @enumFromInt(1) }; |
| 28 | 30 | } |
| 29 | 31 | |
| 30 | 32 | pub fn stderr() File { |
| 31 | | if (os == .linux) |
| 32 | | return .{ .fd = @enumFromInt(2) }; |
| 33 | return .{ .fd = @enumFromInt(2) }; |
| 34 | } |
| 35 | |
| 36 | pub fn memfd_create(name: [*:0]const u8, flags: c_uint) !File { |
| 37 | return .{ .fd = @enumFromInt(try sys.memfd_create(name, flags)) }; |
| 33 | 38 | } |