| @@ -113,7 +113,7 @@ fn closeFd(fd: std.posix.fd_t) void { |
| 113 | 113 | /// Read entire file contents using POSIX APIs. |
| 114 | 114 | /// Replaces std.fs.cwd().openFile() + file.readToEndAlloc(). |
| 115 | 115 | pub fn readFileAlloc(allocator: std.mem.Allocator, path: []const u8) ![]const u8 { |
| 116 | | - const path_z = try allocator.dupeZ(u8, path); |
| 116 | + const path_z = try allocator.dupeSentinel(u8, path, 0); |
| 117 | 117 | defer allocator.free(path_z); |
| 118 | 118 | |
| 119 | 119 | const fd = std.posix.openatZ(std.posix.AT.FDCWD, path_z, .{}, 0) catch |err| { |
| @@ -139,7 +139,7 @@ pub fn readFileAlloc(allocator: std.mem.Allocator, path: []const u8) ![]const u8 |
| 139 | 139 | /// Write content to a file using POSIX APIs. |
| 140 | 140 | /// Replaces std.fs.cwd().createFile() + file.writeAll(). |
| 141 | 141 | pub fn writeFile(allocator: std.mem.Allocator, path: []const u8, content: []const u8) !void { |
| 142 | | - const path_z = try allocator.dupeZ(u8, path); |
| 142 | + const path_z = try allocator.dupeSentinel(u8, path, 0); |
| 143 | 143 | defer allocator.free(path_z); |
| 144 | 144 | |
| 145 | 145 | const fd = std.posix.openatZ(std.posix.AT.FDCWD, path_z, .{ |
| @@ -161,7 +161,7 @@ pub fn writeFile(allocator: std.mem.Allocator, path: []const u8, content: []cons |
| 161 | 161 | /// Delete a file using POSIX APIs. |
| 162 | 162 | /// Replaces std.fs.cwd().deleteFile(). |
| 163 | 163 | pub fn deleteFile(allocator: std.mem.Allocator, path: []const u8) !void { |
| 164 | | - const path_z = try allocator.dupeZ(u8, path); |
| 164 | + const path_z = try allocator.dupeSentinel(u8, path, 0); |
| 165 | 165 | defer allocator.free(path_z); |
| 166 | 166 | const rc = std.c.unlink(path_z); |
| 167 | 167 | if (rc != 0) { |
| @@ -175,7 +175,7 @@ pub fn deleteFile(allocator: std.mem.Allocator, path: []const u8) !void { |
| 175 | 175 | /// Create directories recursively using POSIX APIs. |
| 176 | 176 | /// Replaces std.fs.cwd().makePath(). |
| 177 | 177 | pub fn makePath(allocator: std.mem.Allocator, path: []const u8) !void { |
| 178 | | - const path_z = try allocator.dupeZ(u8, path); |
| 178 | + const path_z = try allocator.dupeSentinel(u8, path, 0); |
| 179 | 179 | defer allocator.free(path_z); |
| 180 | 180 | |
| 181 | 181 | const rc = std.c.mkdir(path_z, 0o755); |
| @@ -189,7 +189,7 @@ pub fn makePath(allocator: std.mem.Allocator, path: []const u8) !void { |
| 189 | 189 | if (sep > 0) { |
| 190 | 190 | try makePath(allocator, path[0..sep]); |
| 191 | 191 | // Retry creating the directory |
| 192 | | - const retry_z = try allocator.dupeZ(u8, path); |
| 192 | + const retry_z = try allocator.dupeSentinel(u8, path, 0); |
| 193 | 193 | defer allocator.free(retry_z); |
| 194 | 194 | const rc2 = std.c.mkdir(retry_z, 0o755); |
| 195 | 195 | if (rc2 != 0 and std.c.errno(rc2) != .EXIST) { |
| @@ -298,7 +298,7 @@ pub fn spawnAndWait( |
| 298 | 298 | defer allocator.free(c_argv); |
| 299 | 299 | |
| 300 | 300 | for (argv, 0..) |arg, i| { |
| 301 | | - const z = try allocator.dupeZ(u8, arg); |
| 301 | + const z = try allocator.dupeSentinel(u8, arg, 0); |
| 302 | 302 | c_argv[i] = z.ptr; |
| 303 | 303 | } |
| 304 | 304 | c_argv[argv.len] = null; |