| ... | ... | @@ -251,7 +251,7 @@ test "Dir.readLink on non-symlinks" { |
| 251 | 251 | |
| 252 | 252 | fn testReadLink(io: Io, dir: Dir, target_path: []const u8, symlink_path: []const u8) !void { |
| 253 | 253 | var buffer: [Dir.max_path_bytes]u8 = undefined; |
| 254 | | const actual = try dir.readLink(io, symlink_path, &buffer); |
| 254 | const actual = buffer[0..try dir.readLink(io, symlink_path, &buffer)]; |
| 255 | 255 | try expectEqualStrings(target_path, actual); |
| 256 | 256 | } |
| 257 | 257 | |
| ... | ... | @@ -289,7 +289,7 @@ test "File.stat on a File that is a symlink returns Kind.sym_link" { |
| 289 | 289 | |
| 290 | 290 | try setupSymlink(io, ctx.dir, dir_target_path, "symlink", .{ .is_directory = true }); |
| 291 | 291 | |
| 292 | | var symlink: Dir = try ctx.dir.openDir("symlink", .{ .follow_symlinks = false }); |
| 292 | var symlink: Dir = try ctx.dir.openDir(io, "symlink", .{ .follow_symlinks = false }); |
| 293 | 293 | defer symlink.close(io); |
| 294 | 294 | |
| 295 | 295 | const stat = try symlink.stat(io); |
| ... | ... | @@ -807,7 +807,7 @@ test "directory operations on files" { |
| 807 | 807 | try expectError(error.NotDir, ctx.dir.deleteDir(io, test_file_name)); |
| 808 | 808 | |
| 809 | 809 | if (ctx.path_type == .absolute and comptime PathType.absolute.isSupported(builtin.os)) { |
| 810 | | try expectError(error.PathAlreadyExists, Dir.makeDirAbsolute(io, test_file_name)); |
| 810 | try expectError(error.PathAlreadyExists, Dir.makeDirAbsolute(io, test_file_name, .default_dir)); |
| 811 | 811 | try expectError(error.NotDir, Dir.deleteDirAbsolute(io, test_file_name)); |
| 812 | 812 | } |
| 813 | 813 | |
| ... | ... | @@ -1104,9 +1104,9 @@ test "renameAbsolute" { |
| 1104 | 1104 | const base_path = try tmp_dir.dir.realPathAlloc(io, ".", allocator); |
| 1105 | 1105 | |
| 1106 | 1106 | try expectError(error.FileNotFound, Dir.renameAbsolute( |
| 1107 | | io, |
| 1108 | 1107 | try Dir.path.join(allocator, &.{ base_path, "missing_file_name" }), |
| 1109 | 1108 | try Dir.path.join(allocator, &.{ base_path, "something_else" }), |
| 1109 | io, |
| 1110 | 1110 | )); |
| 1111 | 1111 | |
| 1112 | 1112 | // Renaming files |
| ... | ... | @@ -1115,9 +1115,9 @@ test "renameAbsolute" { |
| 1115 | 1115 | var file = try tmp_dir.dir.createFile(io, test_file_name, .{ .read = true }); |
| 1116 | 1116 | file.close(io); |
| 1117 | 1117 | try Dir.renameAbsolute( |
| 1118 | | io, |
| 1119 | 1118 | try Dir.path.join(allocator, &.{ base_path, test_file_name }), |
| 1120 | 1119 | try Dir.path.join(allocator, &.{ base_path, renamed_test_file_name }), |
| 1120 | io, |
| 1121 | 1121 | ); |
| 1122 | 1122 | |
| 1123 | 1123 | // ensure the file was renamed |
| ... | ... | @@ -1132,9 +1132,9 @@ test "renameAbsolute" { |
| 1132 | 1132 | const renamed_test_dir_name = "test_dir_renamed"; |
| 1133 | 1133 | try tmp_dir.dir.makeDir(io, test_dir_name, .default_dir); |
| 1134 | 1134 | try Dir.renameAbsolute( |
| 1135 | | io, |
| 1136 | 1135 | try Dir.path.join(allocator, &.{ base_path, test_dir_name }), |
| 1137 | 1136 | try Dir.path.join(allocator, &.{ base_path, renamed_test_dir_name }), |
| 1137 | io, |
| 1138 | 1138 | ); |
| 1139 | 1139 | |
| 1140 | 1140 | // ensure the directory was renamed |
| ... | ... | @@ -1430,7 +1430,7 @@ test "writev, readv" { |
| 1430 | 1430 | var src_file = try tmp.dir.createFile(io, "test.txt", .{ .read = true }); |
| 1431 | 1431 | defer src_file.close(io); |
| 1432 | 1432 | |
| 1433 | | var writer = src_file.writerStreaming(&.{}); |
| 1433 | var writer = src_file.writerStreaming(io, &.{}); |
| 1434 | 1434 | |
| 1435 | 1435 | try writer.interface.writeVecAll(&write_vecs); |
| 1436 | 1436 | try writer.interface.flush(); |
| ... | ... | @@ -1590,10 +1590,10 @@ test "copyFile" { |
| 1590 | 1590 | try ctx.dir.writeFile(io, .{ .sub_path = src_file, .data = data }); |
| 1591 | 1591 | defer ctx.dir.deleteFile(io, src_file) catch {}; |
| 1592 | 1592 | |
| 1593 | | try ctx.dir.copyFile(src_file, ctx.dir, dest_file, .{}); |
| 1593 | try ctx.dir.copyFile(src_file, ctx.dir, dest_file, io, .{}); |
| 1594 | 1594 | defer ctx.dir.deleteFile(io, dest_file) catch {}; |
| 1595 | 1595 | |
| 1596 | | try ctx.dir.copyFile(src_file, ctx.dir, dest_file2, .{ .override_mode = File.default_mode }); |
| 1596 | try ctx.dir.copyFile(src_file, ctx.dir, dest_file2, io, .{ .override_mode = File.default_mode }); |
| 1597 | 1597 | defer ctx.dir.deleteFile(io, dest_file2) catch {}; |
| 1598 | 1598 | |
| 1599 | 1599 | try expectFileContents(io, ctx.dir, dest_file, data); |
| ... | ... | @@ -1968,7 +1968,7 @@ test "'.' and '..' in Dir functions" { |
| 1968 | 1968 | created_file.close(io); |
| 1969 | 1969 | try ctx.dir.access(io, file_path, .{}); |
| 1970 | 1970 | |
| 1971 | | try ctx.dir.copyFile(file_path, ctx.dir, copy_path, .{}); |
| 1971 | try ctx.dir.copyFile(file_path, ctx.dir, copy_path, io, .{}); |
| 1972 | 1972 | try ctx.dir.rename(copy_path, ctx.dir, rename_path, io); |
| 1973 | 1973 | const renamed_file = try ctx.dir.openFile(io, rename_path, .{}); |
| 1974 | 1974 | renamed_file.close(io); |
| ... | ... | @@ -2000,7 +2000,7 @@ test "'.' and '..' in absolute functions" { |
| 2000 | 2000 | const base_path = try tmp.dir.realPathAlloc(io, ".", allocator); |
| 2001 | 2001 | |
| 2002 | 2002 | const subdir_path = try Dir.path.join(allocator, &.{ base_path, "./subdir" }); |
| 2003 | | try Dir.makeDirAbsolute(io, subdir_path); |
| 2003 | try Dir.makeDirAbsolute(io, subdir_path, .default_dir); |
| 2004 | 2004 | try Dir.accessAbsolute(io, subdir_path, .{}); |
| 2005 | 2005 | var created_subdir = try Dir.openDirAbsolute(io, subdir_path, .{}); |
| 2006 | 2006 | created_subdir.close(io); |
| ... | ... | @@ -2011,10 +2011,10 @@ test "'.' and '..' in absolute functions" { |
| 2011 | 2011 | try Dir.accessAbsolute(io, created_file_path, .{}); |
| 2012 | 2012 | |
| 2013 | 2013 | const copied_file_path = try Dir.path.join(allocator, &.{ subdir_path, "../copy" }); |
| 2014 | | try Dir.copyFileAbsolute(io, created_file_path, copied_file_path, .{}); |
| 2014 | try Dir.copyFileAbsolute(created_file_path, copied_file_path, io, .{}); |
| 2015 | 2015 | const renamed_file_path = try Dir.path.join(allocator, &.{ subdir_path, "../rename" }); |
| 2016 | | try Dir.renameAbsolute(io, copied_file_path, renamed_file_path); |
| 2017 | | const renamed_file = try Dir.openFileAbsolute(renamed_file_path, .{}); |
| 2016 | try Dir.renameAbsolute(copied_file_path, renamed_file_path, io); |
| 2017 | const renamed_file = try Dir.openFileAbsolute(io, renamed_file_path, .{}); |
| 2018 | 2018 | renamed_file.close(io); |
| 2019 | 2019 | try Dir.deleteFileAbsolute(io, renamed_file_path); |
| 2020 | 2020 | |
| ... | ... | @@ -2044,7 +2044,7 @@ test "chmod" { |
| 2044 | 2044 | try expectEqual(0o700, (try dir.stat(io)).permissions.toMode() & 0o7777); |
| 2045 | 2045 | } |
| 2046 | 2046 | |
| 2047 | | test "chown" { |
| 2047 | test "change ownership" { |
| 2048 | 2048 | if (native_os == .windows or native_os == .wasi) |
| 2049 | 2049 | return error.SkipZigTest; |
| 2050 | 2050 | |
| ... | ... | @@ -2055,13 +2055,13 @@ test "chown" { |
| 2055 | 2055 | |
| 2056 | 2056 | const file = try tmp.dir.createFile(io, "test_file", .{}); |
| 2057 | 2057 | defer file.close(io); |
| 2058 | | try file.chown(null, null); |
| 2058 | try file.setOwner(io, null, null); |
| 2059 | 2059 | |
| 2060 | 2060 | try tmp.dir.makeDir(io, "test_dir", .default_dir); |
| 2061 | 2061 | |
| 2062 | 2062 | var dir = try tmp.dir.openDir(io, "test_dir", .{ .iterate = true }); |
| 2063 | 2063 | defer dir.close(io); |
| 2064 | | try dir.chown(null, null); |
| 2064 | try dir.setOwner(io, null, null); |
| 2065 | 2065 | } |
| 2066 | 2066 | |
| 2067 | 2067 | test "invalid UTF-8/WTF-8 paths" { |
| ... | ... | @@ -2116,7 +2116,7 @@ test "invalid UTF-8/WTF-8 paths" { |
| 2116 | 2116 | |
| 2117 | 2117 | var dir = ctx.dir; |
| 2118 | 2118 | try expectError(expected_err, dir.updateFile(io, invalid_path, dir, invalid_path, .{})); |
| 2119 | | try expectError(expected_err, ctx.dir.copyFile(invalid_path, ctx.dir, invalid_path, .{})); |
| 2119 | try expectError(expected_err, ctx.dir.copyFile(invalid_path, ctx.dir, invalid_path, io, .{})); |
| 2120 | 2120 | |
| 2121 | 2121 | try expectError(expected_err, ctx.dir.statFile(invalid_path)); |
| 2122 | 2122 | |
| ... | ... | @@ -2128,12 +2128,12 @@ test "invalid UTF-8/WTF-8 paths" { |
| 2128 | 2128 | try expectError(expected_err, Dir.rename(ctx.dir, invalid_path, ctx.dir, invalid_path, io)); |
| 2129 | 2129 | |
| 2130 | 2130 | if (native_os != .wasi and ctx.path_type != .relative) { |
| 2131 | | try expectError(expected_err, Dir.copyFileAbsolute(invalid_path, invalid_path, .{})); |
| 2132 | | try expectError(expected_err, Dir.makeDirAbsolute(invalid_path)); |
| 2131 | try expectError(expected_err, Dir.copyFileAbsolute(invalid_path, invalid_path, io, .{})); |
| 2132 | try expectError(expected_err, Dir.makeDirAbsolute(io, invalid_path, .default_dir)); |
| 2133 | 2133 | try expectError(expected_err, Dir.deleteDirAbsolute(invalid_path)); |
| 2134 | | try expectError(expected_err, Dir.renameAbsolute(invalid_path, invalid_path)); |
| 2134 | try expectError(expected_err, Dir.renameAbsolute(invalid_path, invalid_path, io)); |
| 2135 | 2135 | try expectError(expected_err, Dir.openDirAbsolute(io, invalid_path, .{})); |
| 2136 | | try expectError(expected_err, Dir.openFileAbsolute(invalid_path, .{})); |
| 2136 | try expectError(expected_err, Dir.openFileAbsolute(io, invalid_path, .{})); |
| 2137 | 2137 | try expectError(expected_err, Dir.accessAbsolute(invalid_path, .{})); |
| 2138 | 2138 | try expectError(expected_err, Dir.createFileAbsolute(invalid_path, .{})); |
| 2139 | 2139 | try expectError(expected_err, Dir.deleteFileAbsolute(invalid_path)); |
| ... | ... | @@ -2157,7 +2157,7 @@ test "read file non vectored" { |
| 2157 | 2157 | const file = try tmp_dir.dir.createFile(io, "input.txt", .{ .read = true }); |
| 2158 | 2158 | defer file.close(io); |
| 2159 | 2159 | { |
| 2160 | | var file_writer: File.Writer = .init(file, &.{}); |
| 2160 | var file_writer: File.Writer = .init(file, io, &.{}); |
| 2161 | 2161 | try file_writer.interface.writeAll(contents); |
| 2162 | 2162 | try file_writer.interface.flush(); |
| 2163 | 2163 | } |
| ... | ... | @@ -2189,7 +2189,7 @@ test "seek keeping partial buffer" { |
| 2189 | 2189 | const file = try tmp_dir.dir.createFile(io, "input.txt", .{ .read = true }); |
| 2190 | 2190 | defer file.close(io); |
| 2191 | 2191 | { |
| 2192 | | var file_writer: File.Writer = .init(file, &.{}); |
| 2192 | var file_writer: File.Writer = .init(file, io, &.{}); |
| 2193 | 2193 | try file_writer.interface.writeAll(contents); |
| 2194 | 2194 | try file_writer.interface.flush(); |
| 2195 | 2195 | } |
| ... | ... | @@ -2251,7 +2251,7 @@ test "seekTo flushes buffered data" { |
| 2251 | 2251 | defer file.close(io); |
| 2252 | 2252 | { |
| 2253 | 2253 | var buf: [16]u8 = undefined; |
| 2254 | | var file_writer = file.writer(io, file, &buf); |
| 2254 | var file_writer = file.writer(io, &buf); |
| 2255 | 2255 | |
| 2256 | 2256 | try file_writer.interface.writeAll(contents); |
| 2257 | 2257 | try file_writer.seekTo(8); |
| ... | ... | @@ -2285,7 +2285,7 @@ test "File.Writer sendfile with buffered contents" { |
| 2285 | 2285 | try in_r.interface.fill(2); |
| 2286 | 2286 | |
| 2287 | 2287 | var out_buf: [1]u8 = undefined; |
| 2288 | | var out_w = out.writerStreaming(&out_buf); |
| 2288 | var out_w = out.writerStreaming(io, &out_buf); |
| 2289 | 2289 | try out_w.interface.writeByte('a'); |
| 2290 | 2290 | try expectEqual(3, try out_w.interface.sendFileAll(&in_r, .unlimited)); |
| 2291 | 2291 | try out_w.interface.flush(); |
| ... | ... | @@ -2325,16 +2325,17 @@ test "readlinkat" { |
| 2325 | 2325 | try tmp.dir.writeFile(io, .{ .sub_path = "file.txt", .data = "nonsense" }); |
| 2326 | 2326 | |
| 2327 | 2327 | // create a symbolic link |
| 2328 | | tmp.dir.symLink("file.txt", "link", .{}) catch |err| switch (err) { |
| 2328 | tmp.dir.symLink(io, "file.txt", "link", .{}) catch |err| switch (err) { |
| 2329 | 2329 | error.AccessDenied => { |
| 2330 | 2330 | // Symlink requires admin privileges on windows, so this test can legitimately fail. |
| 2331 | 2331 | if (native_os == .windows) return error.SkipZigTest; |
| 2332 | 2332 | }, |
| 2333 | else => |e| return e, |
| 2333 | 2334 | }; |
| 2334 | 2335 | |
| 2335 | 2336 | // read the link |
| 2336 | 2337 | var buffer: [Dir.max_path_bytes]u8 = undefined; |
| 2337 | | const read_link = try tmp.dir.readLink(io, "link", &buffer); |
| 2338 | const read_link = buffer[0..try tmp.dir.readLink(io, "link", &buffer)]; |
| 2338 | 2339 | try expectEqualStrings("file.txt", read_link); |
| 2339 | 2340 | } |
| 2340 | 2341 | |
| ... | ... | @@ -2351,7 +2352,7 @@ test "fchmodat smoke test" { |
| 2351 | 2352 | var tmp = tmpDir(.{}); |
| 2352 | 2353 | defer tmp.cleanup(); |
| 2353 | 2354 | |
| 2354 | | try expectError(error.FileNotFound, tmp.dir.setPermissions(io, "regfile", 0o666, .{})); |
| 2355 | try expectError(error.FileNotFound, tmp.dir.setFilePermissions(io, "regfile", .fromMode(0o666), .{})); |
| 2355 | 2356 | const file = try tmp.dir.createFile(io, "regfile", .{ |
| 2356 | 2357 | .exclusive = true, |
| 2357 | 2358 | .permissions = .fromMode(0o644), |
| ... | ... | @@ -2384,15 +2385,15 @@ test "fchmodat smoke test" { |
| 2384 | 2385 | error.OperationNotSupported => test_link = false, |
| 2385 | 2386 | else => |e| return e, |
| 2386 | 2387 | }; |
| 2387 | | if (test_link) |
| 2388 | | try expectMode(tmp.dir.handle, "symlink", 0o600); |
| 2389 | | try expectMode(tmp.dir.handle, "regfile", 0o640); |
| 2388 | if (test_link) try expectMode(io, tmp.dir, "symlink", .fromMode(0o600)); |
| 2389 | try expectMode(io, tmp.dir, "regfile", .fromMode(0o640)); |
| 2390 | 2390 | } |
| 2391 | 2391 | |
| 2392 | 2392 | fn expectMode(io: Io, dir: Dir, file: []const u8, permissions: File.Permissions) !void { |
| 2393 | 2393 | const mode = permissions.toMode(); |
| 2394 | 2394 | const st = try dir.statFile(io, file, .{ .follow_symlinks = false }); |
| 2395 | | try expectEqual(mode, st.mode & 0b111_111_111); |
| 2395 | const found_mode = st.permissions.toMode(); |
| 2396 | try expectEqual(mode, found_mode & 0b111_111_111); |
| 2396 | 2397 | } |
| 2397 | 2398 | |
| 2398 | 2399 | test "isatty" { |
| ... | ... | @@ -2417,7 +2418,7 @@ test "read positional empty buffer" { |
| 2417 | 2418 | defer file.close(io); |
| 2418 | 2419 | |
| 2419 | 2420 | var buffer: [0]u8 = undefined; |
| 2420 | | try expectEqual(0, try file.readPositional(io, &buffer, 0)); |
| 2421 | try expectEqual(0, try file.readPositional(io, &.{&buffer}, 0)); |
| 2421 | 2422 | } |
| 2422 | 2423 | |
| 2423 | 2424 | test "write streaming empty buffer" { |
| ... | ... | @@ -2429,8 +2430,8 @@ test "write streaming empty buffer" { |
| 2429 | 2430 | var file = try tmp.dir.createFile(io, "write_empty", .{}); |
| 2430 | 2431 | defer file.close(io); |
| 2431 | 2432 | |
| 2432 | | var buffer: [0]u8 = &.{}; |
| 2433 | | try expectEqual(0, try file.writeStreaming(io, &buffer)); |
| 2433 | const buffer: [0]u8 = .{}; |
| 2434 | try file.writeStreamingAll(io, &buffer); |
| 2434 | 2435 | } |
| 2435 | 2436 | |
| 2436 | 2437 | test "write positional empty buffer" { |
| ... | ... | @@ -2442,8 +2443,8 @@ test "write positional empty buffer" { |
| 2442 | 2443 | var file = try tmp.dir.createFile(io, "pwrite_empty", .{}); |
| 2443 | 2444 | defer file.close(io); |
| 2444 | 2445 | |
| 2445 | | var buffer: [0]u8 = &.{}; |
| 2446 | | try expectEqual(0, try file.writePositional(io, &buffer, 0)); |
| 2446 | const buffer: [0]u8 = .{}; |
| 2447 | try expectEqual(0, try file.writePositional(io, &.{&buffer}, 0)); |
| 2447 | 2448 | } |
| 2448 | 2449 | |
| 2449 | 2450 | test "access smoke test" { |
| ... | ... | @@ -2452,53 +2453,38 @@ test "access smoke test" { |
| 2452 | 2453 | if (native_os == .openbsd) return error.SkipZigTest; |
| 2453 | 2454 | |
| 2454 | 2455 | const io = testing.io; |
| 2455 | | const gpa = testing.allocator; |
| 2456 | 2456 | |
| 2457 | 2457 | var tmp = tmpDir(.{}); |
| 2458 | 2458 | defer tmp.cleanup(); |
| 2459 | 2459 | |
| 2460 | | const base_path = try tmp.dir.realPathAlloc(io, ".", gpa); |
| 2461 | | defer gpa.free(base_path); |
| 2462 | | |
| 2463 | 2460 | { |
| 2464 | 2461 | // Create some file using `open`. |
| 2465 | | const file_path = try Dir.path.join(gpa, &.{ base_path, "some_file" }); |
| 2466 | | defer gpa.free(file_path); |
| 2467 | | const file = Dir.cwd().createFile(io, file_path, .{ .read = true, .exclusive = true }); |
| 2462 | const file = try tmp.dir.createFile(io, "some_file", .{ .read = true, .exclusive = true }); |
| 2468 | 2463 | file.close(io); |
| 2469 | 2464 | } |
| 2470 | 2465 | |
| 2471 | 2466 | { |
| 2472 | 2467 | // Try to access() the file |
| 2473 | | const file_path = try Dir.path.join(gpa, &.{ base_path, "some_file" }); |
| 2474 | | defer gpa.free(file_path); |
| 2475 | 2468 | if (native_os == .windows) { |
| 2476 | | try Dir.cwd().access(io, file_path, .{}); |
| 2469 | try tmp.dir.access(io, "some_file", .{}); |
| 2477 | 2470 | } else { |
| 2478 | | try Dir.cwd().access(io, file_path, .{ .read = true, .write = true }); |
| 2471 | try tmp.dir.access(io, "some_file", .{ .read = true, .write = true }); |
| 2479 | 2472 | } |
| 2480 | 2473 | } |
| 2481 | 2474 | |
| 2482 | 2475 | { |
| 2483 | 2476 | // Try to access() a non-existent file - should fail with error.FileNotFound |
| 2484 | | const file_path = try Dir.path.join(gpa, &.{ base_path, "some_other_file" }); |
| 2485 | | defer gpa.free(file_path); |
| 2486 | | try expectError(error.FileNotFound, Dir.cwd().access(io, file_path, .{})); |
| 2477 | try expectError(error.FileNotFound, tmp.dir.access(io, "some_other_file", .{})); |
| 2487 | 2478 | } |
| 2488 | 2479 | |
| 2489 | 2480 | { |
| 2490 | 2481 | // Create some directory |
| 2491 | | const file_path = try Dir.path.join(gpa, &.{ base_path, "some_dir" }); |
| 2492 | | defer gpa.free(file_path); |
| 2493 | | try Dir.makeDir(io, file_path, .default_file); |
| 2482 | try tmp.dir.makeDir(io, "some_dir", .default_file); |
| 2494 | 2483 | } |
| 2495 | 2484 | |
| 2496 | 2485 | { |
| 2497 | 2486 | // Try to access() the directory |
| 2498 | | const file_path = try Dir.path.join(gpa, &.{ base_path, "some_dir" }); |
| 2499 | | defer gpa.free(file_path); |
| 2500 | | |
| 2501 | | try Dir.access(io, file_path, .{}); |
| 2487 | try tmp.dir.access(io, "some_dir", .{}); |
| 2502 | 2488 | } |
| 2503 | 2489 | } |
| 2504 | 2490 | |
| ... | ... | @@ -2552,12 +2538,12 @@ test "open smoke test" { |
| 2552 | 2538 | try tmp.dir.makeDir(io, "some_dir", .default_dir); |
| 2553 | 2539 | |
| 2554 | 2540 | { |
| 2555 | | const dir = try tmp.dir.openDir("some_dir", .{}); |
| 2541 | const dir = try tmp.dir.openDir(io, "some_dir", .{}); |
| 2556 | 2542 | dir.close(io); |
| 2557 | 2543 | } |
| 2558 | 2544 | |
| 2559 | 2545 | // Try opening as file which should fail. |
| 2560 | | try expectError(error.IsDir, tmp.dir.openFile("some_dir", .{})); |
| 2546 | try expectError(error.IsDir, tmp.dir.openFile(io, "some_dir", .{})); |
| 2561 | 2547 | } |
| 2562 | 2548 | |
| 2563 | 2549 | test "hard link with different directories" { |
| ... | ... | @@ -2575,7 +2561,7 @@ test "hard link with different directories" { |
| 2575 | 2561 | try tmp.dir.writeFile(io, .{ .sub_path = target_name, .data = "example" }); |
| 2576 | 2562 | |
| 2577 | 2563 | // Test 1: link from file in subdir back up to target in parent directory |
| 2578 | | tmp.dir.hardLink(target_name, subdir, link_name, 0) catch |err| switch (err) { |
| 2564 | tmp.dir.hardLink(target_name, subdir, link_name, io, .{}) catch |err| switch (err) { |
| 2579 | 2565 | error.OperationUnsupported => return error.SkipZigTest, |
| 2580 | 2566 | else => |e| return e, |
| 2581 | 2567 | }; |
| ... | ... | @@ -2596,7 +2582,7 @@ test "hard link with different directories" { |
| 2596 | 2582 | } |
| 2597 | 2583 | |
| 2598 | 2584 | // Test 2: remove link |
| 2599 | | try subdir.deleteFile(io, link_name, .{}); |
| 2585 | try subdir.deleteFile(io, link_name); |
| 2600 | 2586 | const e_stat = try efd.stat(io); |
| 2601 | 2587 | try expectEqual(1, e_stat.nlink); |
| 2602 | 2588 | } |