authorgravatar for github@mjb.ioMichael Bradshaw <github@mjb.io> 2024-06-28 08:21:20-07:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2024-07-03 17:42:09+01:00
log21cad3e09f173154c4c0dc61dd05fe8dd0628dc3
tree716f87eacd02c591b4288fb70d3adf6daa7cac8c
parente1d4cf67caedfe20d2e0af9d3b518af1f0777191

Rename MAX_NAME_BYTES to max_name_bytes


5 files changed, 11 insertions(+), 8 deletions(-)

lib/compiler/aro/aro/Driver.zig+2-2
......@@ -730,8 +730,8 @@ fn processSource(
730730 defer obj.deinit();
731731
732732 // If it's used, name_buf will either hold a filename or `/tmp/<12 random bytes with base-64 encoding>.<extension>`
733 // both of which should fit into MAX_NAME_BYTES for all systems
734 var name_buf: [std.fs.MAX_NAME_BYTES]u8 = undefined;
733 // both of which should fit into max_name_bytes for all systems
734 var name_buf: [std.fs.max_name_bytes]u8 = undefined;
735735
736736 const out_file_name = if (d.only_compile) blk: {
737737 const fmt_template = "{s}{s}";
lib/std/fs.zig+5-2
......@@ -72,7 +72,7 @@ pub const max_path_bytes = switch (native_os) {
7272/// On Windows, `[]u8` file name components are encoded as [WTF-8](https://simonsapin.github.io/wtf-8/).
7373/// On WASI, file name components are encoded as valid UTF-8.
7474/// On other platforms, `[]u8` components are an opaque sequence of bytes with no particular encoding.
75pub const MAX_NAME_BYTES = switch (native_os) {
75pub const max_name_bytes = switch (native_os) {
7676 .linux, .macos, .ios, .freebsd, .openbsd, .netbsd, .dragonfly, .solaris, .illumos => posix.NAME_MAX,
7777 // Haiku's NAME_MAX includes the null terminator, so subtract one.
7878 .haiku => posix.NAME_MAX - 1,
......@@ -81,7 +81,7 @@ pub const MAX_NAME_BYTES = switch (native_os) {
8181 // pair in the WTF-16LE, and we (over)account 3 bytes for it that way.
8282 .windows => windows.NAME_MAX * 3,
8383 // For WASI, the MAX_NAME will depend on the host OS, so it needs to be
84 // as large as the largest MAX_NAME_BYTES (Windows) in order to work on any host OS.
84 // as large as the largest max_name_bytes (Windows) in order to work on any host OS.
8585 // TODO determine if this is a reasonable approach
8686 .wasi => windows.NAME_MAX * 3,
8787 else => if (@hasDecl(root, "os") and @hasDecl(root.os, "NAME_MAX"))
......@@ -90,6 +90,9 @@ pub const MAX_NAME_BYTES = switch (native_os) {
9090 @compileError("NAME_MAX not implemented for " ++ @tagName(native_os)),
9191};
9292
93/// Deprecated: use `max_name_bytes`
94pub const MAX_NAME_BYTES = max_name_bytes;
95
9396pub const base64_alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".*;
9497
9598/// Base64 encoder, replacing the standard `+/` with `-_` so that it can be used in a file name on any filesystem.
lib/std/fs/Dir.zig+1-1
......@@ -414,7 +414,7 @@ pub const Iterator = switch (native_os) {
414414 index: usize,
415415 end_index: usize,
416416 first_iter: bool,
417 name_data: [fs.MAX_NAME_BYTES]u8,
417 name_data: [fs.max_name_bytes]u8,
418418
419419 const Self = @This();
420420
lib/std/fs/test.zig+2-2
......@@ -1269,11 +1269,11 @@ test "max file name component lengths" {
12691269 } else if (native_os == .wasi) {
12701270 // On WASI, the maxed filename depends on the host OS, so in order for this test to
12711271 // work on any host, we need to use a length that will work for all platforms
1272 // (i.e. the minimum MAX_NAME_BYTES of all supported platforms).
1272 // (i.e. the minimum max_name_bytes of all supported platforms).
12731273 const maxed_wasi_filename = [_]u8{'1'} ** 255;
12741274 try testFilenameLimits(tmp.dir, &maxed_wasi_filename);
12751275 } else {
1276 const maxed_ascii_filename = [_]u8{'1'} ** std.fs.MAX_NAME_BYTES;
1276 const maxed_ascii_filename = [_]u8{'1'} ** std.fs.max_name_bytes;
12771277 try testFilenameLimits(tmp.dir, &maxed_ascii_filename);
12781278 }
12791279}
lib/std/zig/WindowsSdk.zig+1-1
......@@ -750,7 +750,7 @@ const MsvcLibDir = struct {
750750 var instances_dir = try findInstancesDir(allocator);
751751 defer instances_dir.close();
752752
753 var state_subpath_buf: [std.fs.MAX_NAME_BYTES + 32]u8 = undefined;
753 var state_subpath_buf: [std.fs.max_name_bytes + 32]u8 = undefined;
754754 var latest_version_lib_dir = std.ArrayListUnmanaged(u8){};
755755 errdefer latest_version_lib_dir.deinit(allocator);
756756