| ... | ... | @@ -1380,12 +1380,12 @@ test "makepath ignores '.'" { |
| 1380 | 1380 | try expectDir(io, tmp.dir, expectedPath); |
| 1381 | 1381 | } |
| 1382 | 1382 | |
| 1383 | | fn testFilenameLimits(io: Io, iterable_dir: Dir, maxed_filename: []const u8) !void { |
| 1383 | fn testFilenameLimits(io: Io, iterable_dir: Dir, maxed_filename: []const u8, maxed_dirname: []const u8) !void { |
| 1384 | 1384 | // create a file, a dir, and a nested file all with maxed filenames |
| 1385 | 1385 | { |
| 1386 | 1386 | try iterable_dir.writeFile(io, .{ .sub_path = maxed_filename, .data = "" }); |
| 1387 | 1387 | |
| 1388 | | var maxed_dir = try iterable_dir.makeOpenPath(io, maxed_filename, .{}); |
| 1388 | var maxed_dir = try iterable_dir.makeOpenPath(io, maxed_dirname, .{}); |
| 1389 | 1389 | defer maxed_dir.close(io); |
| 1390 | 1390 | |
| 1391 | 1391 | try maxed_dir.writeFile(io, .{ .sub_path = maxed_filename, .data = "" }); |
| ... | ... | @@ -1427,18 +1427,23 @@ test "max file name component lengths" { |
| 1427 | 1427 | |
| 1428 | 1428 | if (native_os == .windows) { |
| 1429 | 1429 | // U+FFFF is the character with the largest code point that is encoded as a single |
| 1430 | | // UTF-16 code unit, so Windows allows for NAME_MAX of them. |
| 1431 | | const maxed_windows_filename = ("\u{FFFF}".*) ** windows.NAME_MAX; |
| 1432 | | try testFilenameLimits(io, tmp.dir, &maxed_windows_filename); |
| 1430 | // WTF-16 code unit, so Windows allows for NAME_MAX of them. |
| 1431 | const maxed_windows_filename1 = ("\u{FFFF}".*) ** windows.NAME_MAX; |
| 1432 | // This is also a code point that is encoded as one WTF-16 code unit, but |
| 1433 | // three WTF-8 bytes, so it exercises the limits of both WTF-16 and WTF-8 encodings. |
| 1434 | const maxed_windows_filename2 = ("€".*) ** windows.NAME_MAX; |
| 1435 | try testFilenameLimits(io, tmp.dir, &maxed_windows_filename1, &maxed_windows_filename2); |
| 1433 | 1436 | } else if (native_os == .wasi) { |
| 1434 | 1437 | // On WASI, the maxed filename depends on the host OS, so in order for this test to |
| 1435 | 1438 | // work on any host, we need to use a length that will work for all platforms |
| 1436 | 1439 | // (i.e. the minimum max_name_bytes of all supported platforms). |
| 1437 | | const maxed_wasi_filename = [_]u8{'1'} ** 255; |
| 1438 | | try testFilenameLimits(io, tmp.dir, &maxed_wasi_filename); |
| 1440 | const maxed_wasi_filename1 = [_]u8{'1'} ** 255; |
| 1441 | const maxed_wasi_filename2 = [_]u8{'2'} ** 255; |
| 1442 | try testFilenameLimits(io, tmp.dir, &maxed_wasi_filename1, &maxed_wasi_filename2); |
| 1439 | 1443 | } else { |
| 1440 | | const maxed_ascii_filename = [_]u8{'1'} ** std.fs.max_name_bytes; |
| 1441 | | try testFilenameLimits(io, tmp.dir, &maxed_ascii_filename); |
| 1444 | const maxed_ascii_filename1 = [_]u8{'1'} ** std.fs.max_name_bytes; |
| 1445 | const maxed_ascii_filename2 = [_]u8{'2'} ** std.fs.max_name_bytes; |
| 1446 | try testFilenameLimits(io, tmp.dir, &maxed_ascii_filename1, &maxed_ascii_filename2); |
| 1442 | 1447 | } |
| 1443 | 1448 | } |
| 1444 | 1449 | |