| ... | @@ -7,27 +7,32 @@ pub const File = @import("./File.zig"); | ... | @@ -7,27 +7,32 @@ pub const File = @import("./File.zig"); |
| 7 | | 7 | |
| 8 | const os = builtin.target.os.tag; | 8 | const os = builtin.target.os.tag; |
| 9 | | 9 | |
| | 10 | const sys = switch (os) { |
| | 11 | .linux => sys_linux, |
| | 12 | else => unreachable, |
| | 13 | }; |
| | 14 | |
| 10 | pub const Handle = switch (os) { | 15 | pub const Handle = switch (os) { |
| 11 | .linux => enum(c_int) { _ }, | 16 | .linux => enum(c_int) { _ }, |
| 12 | else => @compileError("TODO"), | 17 | else => unreachable, |
| 13 | }; | 18 | }; |
| 14 | | 19 | |
| 15 | pub fn cwd() Dir { | 20 | pub fn cwd() Dir { |
| 16 | if (os == .linux) | 21 | return .{ .fd = @enumFromInt(sys.AT.FDCWD) }; |
| 17 | return .{ .fd = @enumFromInt(sys_linux.AT.FDCWD) }; | | |
| 18 | } | 22 | } |
| 19 | | 23 | |
| 20 | pub fn stdin() File { | 24 | pub fn stdin() File { |
| 21 | if (os == .linux) | 25 | return .{ .fd = @enumFromInt(0) }; |
| 22 | return .{ .fd = @enumFromInt(0) }; | | |
| 23 | } | 26 | } |
| 24 | | 27 | |
| 25 | pub fn stdout() File { | 28 | pub fn stdout() File { |
| 26 | if (os == .linux) | 29 | return .{ .fd = @enumFromInt(1) }; |
| 27 | return .{ .fd = @enumFromInt(1) }; | | |
| 28 | } | 30 | } |
| 29 | | 31 | |
| 30 | pub fn stderr() File { | 32 | pub fn stderr() File { |
| 31 | if (os == .linux) | 33 | return .{ .fd = @enumFromInt(2) }; |
| 32 | 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 | } |