ReviewOS

also looking at this

zig-utils/zig-test-framework

chore: wip

#1
Merged glennmichael123 wants to merge fix-ci-process into main
3 files +15 -17
src/compat.zigmodified+6-6
Changes to src/compat.zig
@@ -113,7 +113,7 @@ fn closeFd(fd: std.posix.fd_t) void {
113113/// Read entire file contents using POSIX APIs.
114114/// Replaces std.fs.cwd().openFile() + file.readToEndAlloc().
115115pub 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);
117117 defer allocator.free(path_z);
118118
119119 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
139139/// Write content to a file using POSIX APIs.
140140/// Replaces std.fs.cwd().createFile() + file.writeAll().
141141pub 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);
143143 defer allocator.free(path_z);
144144
145145 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
161161/// Delete a file using POSIX APIs.
162162/// Replaces std.fs.cwd().deleteFile().
163163pub 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);
165165 defer allocator.free(path_z);
166166 const rc = std.c.unlink(path_z);
167167 if (rc != 0) {
@@ -175,7 +175,7 @@ pub fn deleteFile(allocator: std.mem.Allocator, path: []const u8) !void {
175175/// Create directories recursively using POSIX APIs.
176176/// Replaces std.fs.cwd().makePath().
177177pub 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);
179179 defer allocator.free(path_z);
180180
181181 const rc = std.c.mkdir(path_z, 0o755);
@@ -189,7 +189,7 @@ pub fn makePath(allocator: std.mem.Allocator, path: []const u8) !void {
189189 if (sep > 0) {
190190 try makePath(allocator, path[0..sep]);
191191 // Retry creating the directory
192 const retry_z = try allocator.dupeZ(u8, path);
192 const retry_z = try allocator.dupeSentinel(u8, path, 0);
193193 defer allocator.free(retry_z);
194194 const rc2 = std.c.mkdir(retry_z, 0o755);
195195 if (rc2 != 0 and std.c.errno(rc2) != .EXIST) {
@@ -298,7 +298,7 @@ pub fn spawnAndWait(
298298 defer allocator.free(c_argv);
299299
300300 for (argv, 0..) |arg, i| {
301 const z = try allocator.dupeZ(u8, arg);
301 const z = try allocator.dupeSentinel(u8, arg, 0);
302302 c_argv[i] = z.ptr;
303303 }
304304 c_argv[argv.len] = null;