| ... | @@ -44,3 +44,11 @@ pub fn memfd_create(name: [*:0]const u8, flags: c_uint) !File { | ... | @@ -44,3 +44,11 @@ pub fn memfd_create(name: [*:0]const u8, flags: c_uint) !File { |
| 44 | pub fn munmap(region: []const u8) void { | 44 | pub fn munmap(region: []const u8) void { |
| 45 | return sys.munmap(region.ptr, region.len) catch {}; | 45 | return sys.munmap(region.ptr, region.len) catch {}; |
| 46 | } | 46 | } |
| | 47 | |
| | 48 | pub fn mkdtemp() !Dir { |
| | 49 | var template = "/tmp/tmp.XXXXXX\x00".*; |
| | 50 | const path_p = try sys.mkdtemp(template[0 .. template.len - 1 :0].ptr); |
| | 51 | const path = std.mem.sliceTo(path_p, 0); |
| | 52 | std.log.debug("path: {s}", .{path}); |
| | 53 | return cwd().openDir(path, .{}); |
| | 54 | } |