authorgravatar for squeek502@hotmail.comRyan Liptak <squeek502@hotmail.com> 2024-05-02 20:20:41-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-06-13 10:18:59-04:00
log76fb2b685b202ea665b850338e353c7816f5b2bb
tree16b4b39db7541febd2b4bf92c041239bdd45f144
parent4aa15440c7a12bcc6bc0cd589ade02295549d48c

std: Convert deprecated aliases to compile errors and fix usages

Deprecated aliases that are now compile errors: - `std.fs.MAX_PATH_BYTES` (renamed to `std.fs.max_path_bytes`) - `std.mem.tokenize` (split into `tokenizeAny`, `tokenizeSequence`, `tokenizeScalar`) - `std.mem.split` (split into `splitSequence`, `splitAny`, `splitScalar`) - `std.mem.splitBackwards` (split into `splitBackwardsSequence`, `splitBackwardsAny`, `splitBackwardsScalar`) - `std.unicode` + `utf16leToUtf8Alloc`, `utf16leToUtf8AllocZ`, `utf16leToUtf8`, `fmtUtf16le` (all renamed to have capitalized `Le`) + `utf8ToUtf16LeWithNull` (renamed to `utf8ToUtf16LeAllocZ`) - `std.zig.CrossTarget` (moved to `std.Target.Query`) Deprecated `lib/std/std.zig` decls were deleted instead of made a `@compileError` because the `refAllDecls` in the test block would trigger the `@compileError`. The deleted top-level `std` namespaces are: - `std.rand` (renamed to `std.Random`) - `std.TailQueue` (renamed to `std.DoublyLinkedList`) - `std.ChildProcess` (renamed/moved to `std.process.Child`) This is not exhaustive. Deprecated aliases that I didn't touch: + `std.io.*` + `std.Build.*` + `std.builtin.Mode` + `std.zig.c_translation.CIntLiteralRadix` + anything in `src/`

47 files changed, 136 insertions(+), 150 deletions(-)

build.zig+2-2
...@@ -15,7 +15,7 @@ const stack_size = 32 * 1024 * 1024;...@@ -15,7 +15,7 @@ const stack_size = 32 * 1024 * 1024;
15pub fn build(b: *std.Build) !void {15pub fn build(b: *std.Build) !void {
16 const only_c = b.option(bool, "only-c", "Translate the Zig compiler to C code, with only the C backend enabled") orelse false;16 const only_c = b.option(bool, "only-c", "Translate the Zig compiler to C code, with only the C backend enabled") orelse false;
17 const target = t: {17 const target = t: {
18 var default_target: std.zig.CrossTarget = .{};18 var default_target: std.Target.Query = .{};
19 default_target.ofmt = b.option(std.Target.ObjectFormat, "ofmt", "Object format to target") orelse if (only_c) .c else null;19 default_target.ofmt = b.option(std.Target.ObjectFormat, "ofmt", "Object format to target") orelse if (only_c) .c else null;
20 break :t b.standardTargetOptions(.{ .default_target = default_target });20 break :t b.standardTargetOptions(.{ .default_target = default_target });
21 };21 };
...@@ -559,7 +559,7 @@ pub fn build(b: *std.Build) !void {...@@ -559,7 +559,7 @@ pub fn build(b: *std.Build) !void {
559fn addWasiUpdateStep(b: *std.Build, version: [:0]const u8) !void {559fn addWasiUpdateStep(b: *std.Build, version: [:0]const u8) !void {
560 const semver = try std.SemanticVersion.parse(version);560 const semver = try std.SemanticVersion.parse(version);
561561
562 var target_query: std.zig.CrossTarget = .{562 var target_query: std.Target.Query = .{
563 .cpu_arch = .wasm32,563 .cpu_arch = .wasm32,
564 .os_tag = .wasi,564 .os_tag = .wasi,
565 };565 };
lib/compiler/aro/aro/Driver.zig+1-1
...@@ -792,7 +792,7 @@ pub fn invokeLinker(d: *Driver, tc: *Toolchain, comptime fast_exit: bool) !void...@@ -792,7 +792,7 @@ pub fn invokeLinker(d: *Driver, tc: *Toolchain, comptime fast_exit: bool) !void
792 var argv = std.ArrayList([]const u8).init(d.comp.gpa);792 var argv = std.ArrayList([]const u8).init(d.comp.gpa);
793 defer argv.deinit();793 defer argv.deinit();
794794
795 var linker_path_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;795 var linker_path_buf: [std.fs.max_path_bytes]u8 = undefined;
796 const linker_path = try tc.getLinkerPath(&linker_path_buf);796 const linker_path = try tc.getLinkerPath(&linker_path_buf);
797 try argv.append(linker_path);797 try argv.append(linker_path);
798798
lib/compiler/aro/aro/Driver/Filesystem.zig+2-2
...@@ -46,7 +46,7 @@ fn canExecuteFake(entries: []const Filesystem.Entry, path: []const u8) bool {...@@ -46,7 +46,7 @@ fn canExecuteFake(entries: []const Filesystem.Entry, path: []const u8) bool {
4646
47fn existsFake(entries: []const Filesystem.Entry, path: []const u8) bool {47fn existsFake(entries: []const Filesystem.Entry, path: []const u8) bool {
48 @setCold(true);48 @setCold(true);
49 var buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;49 var buf: [std.fs.max_path_bytes]u8 = undefined;
50 var fib = std.heap.FixedBufferAllocator.init(&buf);50 var fib = std.heap.FixedBufferAllocator.init(&buf);
51 const resolved = std.fs.path.resolvePosix(fib.allocator(), &.{path}) catch return false;51 const resolved = std.fs.path.resolvePosix(fib.allocator(), &.{path}) catch return false;
52 for (entries) |entry| {52 for (entries) |entry| {
...@@ -181,7 +181,7 @@ pub const Filesystem = union(enum) {...@@ -181,7 +181,7 @@ pub const Filesystem = union(enum) {
181 }181 }
182182
183 pub fn joinedExists(fs: Filesystem, parts: []const []const u8) bool {183 pub fn joinedExists(fs: Filesystem, parts: []const []const u8) bool {
184 var buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;184 var buf: [std.fs.max_path_bytes]u8 = undefined;
185 var fib = std.heap.FixedBufferAllocator.init(&buf);185 var fib = std.heap.FixedBufferAllocator.init(&buf);
186 const joined = std.fs.path.join(fib.allocator(), parts) catch return false;186 const joined = std.fs.path.join(fib.allocator(), parts) catch return false;
187 return fs.exists(joined);187 return fs.exists(joined);
lib/compiler/aro/aro/Driver/GCCDetector.zig+2-2
...@@ -397,7 +397,7 @@ fn collectLibDirsAndTriples(...@@ -397,7 +397,7 @@ fn collectLibDirsAndTriples(
397}397}
398398
399pub fn discover(self: *GCCDetector, tc: *Toolchain) !void {399pub fn discover(self: *GCCDetector, tc: *Toolchain) !void {
400 var path_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;400 var path_buf: [std.fs.max_path_bytes]u8 = undefined;
401 var fib = std.heap.FixedBufferAllocator.init(&path_buf);401 var fib = std.heap.FixedBufferAllocator.init(&path_buf);
402402
403 const target = tc.getTarget();403 const target = tc.getTarget();
...@@ -589,7 +589,7 @@ fn scanLibDirForGCCTriple(...@@ -589,7 +589,7 @@ fn scanLibDirForGCCTriple(
589 gcc_dir_exists: bool,589 gcc_dir_exists: bool,
590 gcc_cross_dir_exists: bool,590 gcc_cross_dir_exists: bool,
591) !void {591) !void {
592 var path_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;592 var path_buf: [std.fs.max_path_bytes]u8 = undefined;
593 var fib = std.heap.FixedBufferAllocator.init(&path_buf);593 var fib = std.heap.FixedBufferAllocator.init(&path_buf);
594 for (0..2) |i| {594 for (0..2) |i| {
595 if (i == 0 and !gcc_dir_exists) continue;595 if (i == 0 and !gcc_dir_exists) continue;
lib/compiler/aro/aro/Toolchain.zig+3-3
...@@ -221,7 +221,7 @@ pub fn addFilePathLibArgs(tc: *const Toolchain, argv: *std.ArrayList([]const u8)...@@ -221,7 +221,7 @@ pub fn addFilePathLibArgs(tc: *const Toolchain, argv: *std.ArrayList([]const u8)
221/// If not found there, just use `name`221/// If not found there, just use `name`
222/// Writes the result to `buf` and returns a slice of it222/// Writes the result to `buf` and returns a slice of it
223fn getProgramPath(tc: *const Toolchain, name: []const u8, buf: []u8) []const u8 {223fn getProgramPath(tc: *const Toolchain, name: []const u8, buf: []u8) []const u8 {
224 var path_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;224 var path_buf: [std.fs.max_path_bytes]u8 = undefined;
225 var fib = std.heap.FixedBufferAllocator.init(&path_buf);225 var fib = std.heap.FixedBufferAllocator.init(&path_buf);
226226
227 var tool_specific_buf: [64]u8 = undefined;227 var tool_specific_buf: [64]u8 = undefined;
...@@ -251,7 +251,7 @@ pub fn getSysroot(tc: *const Toolchain) []const u8 {...@@ -251,7 +251,7 @@ pub fn getSysroot(tc: *const Toolchain) []const u8 {
251/// Search for `name` in a variety of places251/// Search for `name` in a variety of places
252/// TODO: cache results based on `name` so we're not repeatedly allocating the same strings?252/// TODO: cache results based on `name` so we're not repeatedly allocating the same strings?
253pub fn getFilePath(tc: *const Toolchain, name: []const u8) ![]const u8 {253pub fn getFilePath(tc: *const Toolchain, name: []const u8) ![]const u8 {
254 var path_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;254 var path_buf: [std.fs.max_path_bytes]u8 = undefined;
255 var fib = std.heap.FixedBufferAllocator.init(&path_buf);255 var fib = std.heap.FixedBufferAllocator.init(&path_buf);
256 const allocator = fib.allocator();256 const allocator = fib.allocator();
257257
...@@ -304,7 +304,7 @@ const PathKind = enum {...@@ -304,7 +304,7 @@ const PathKind = enum {
304/// Join `components` into a path. If the path exists, dupe it into the toolchain arena and304/// Join `components` into a path. If the path exists, dupe it into the toolchain arena and
305/// add it to the specified path list.305/// add it to the specified path list.
306pub fn addPathIfExists(tc: *Toolchain, components: []const []const u8, dest_kind: PathKind) !void {306pub fn addPathIfExists(tc: *Toolchain, components: []const []const u8, dest_kind: PathKind) !void {
307 var path_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;307 var path_buf: [std.fs.max_path_bytes]u8 = undefined;
308 var fib = std.heap.FixedBufferAllocator.init(&path_buf);308 var fib = std.heap.FixedBufferAllocator.init(&path_buf);
309309
310 const candidate = try std.fs.path.join(fib.allocator(), components);310 const candidate = try std.fs.path.join(fib.allocator(), components);
lib/compiler/aro/aro/Value.zig+1-1
...@@ -706,7 +706,7 @@ pub fn printString(bytes: []const u8, ty: Type, comp: *const Compilation, w: any...@@ -706,7 +706,7 @@ pub fn printString(bytes: []const u8, ty: Type, comp: *const Compilation, w: any
706 switch (size) {706 switch (size) {
707 inline .@"1", .@"2" => |sz| {707 inline .@"1", .@"2" => |sz| {
708 const data_slice: []const sz.Type() = @alignCast(std.mem.bytesAsSlice(sz.Type(), without_null));708 const data_slice: []const sz.Type() = @alignCast(std.mem.bytesAsSlice(sz.Type(), without_null));
709 const formatter = if (sz == .@"1") std.zig.fmtEscapes(data_slice) else std.unicode.fmtUtf16le(data_slice);709 const formatter = if (sz == .@"1") std.zig.fmtEscapes(data_slice) else std.unicode.fmtUtf16Le(data_slice);
710 try w.print("\"{}\"", .{formatter});710 try w.print("\"{}\"", .{formatter});
711 },711 },
712 .@"4" => {712 .@"4" => {
lib/compiler/aro/aro/toolchains/Linux.zig+1-1
...@@ -478,7 +478,7 @@ test Linux {...@@ -478,7 +478,7 @@ test Linux {
478 var argv = std.ArrayList([]const u8).init(driver.comp.gpa);478 var argv = std.ArrayList([]const u8).init(driver.comp.gpa);
479 defer argv.deinit();479 defer argv.deinit();
480480
481 var linker_path_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;481 var linker_path_buf: [std.fs.max_path_bytes]u8 = undefined;
482 const linker_path = try toolchain.getLinkerPath(&linker_path_buf);482 const linker_path = try toolchain.getLinkerPath(&linker_path_buf);
483 try argv.append(linker_path);483 try argv.append(linker_path);
484484
lib/compiler/resinator/cli.zig+1-1
...@@ -846,7 +846,7 @@ pub fn parse(allocator: Allocator, args: []const []const u8, diagnostics: *Diagn...@@ -846,7 +846,7 @@ pub fn parse(allocator: Allocator, args: []const []const u8, diagnostics: *Diagn
846 arg_i += 1;846 arg_i += 1;
847 break :next_arg;847 break :next_arg;
848 };848 };
849 var tokenizer = std.mem.tokenize(u8, value.slice, "=");849 var tokenizer = std.mem.tokenizeScalar(u8, value.slice, '=');
850 // guaranteed to exist since an empty value.slice would invoke850 // guaranteed to exist since an empty value.slice would invoke
851 // the 'missing symbol to define' branch above851 // the 'missing symbol to define' branch above
852 const symbol = tokenizer.next().?;852 const symbol = tokenizer.next().?;
lib/compiler/resinator/compile.zig+1-1
...@@ -3405,7 +3405,7 @@ test "StringTable" {...@@ -3405,7 +3405,7 @@ test "StringTable" {
3405 }3405 }
3406 break :ids buf;3406 break :ids buf;
3407 };3407 };
3408 var prng = std.rand.DefaultPrng.init(0);3408 var prng = std.Random.DefaultPrng.init(0);
3409 var random = prng.random();3409 var random = prng.random();
3410 random.shuffle(u16, &ids);3410 random.shuffle(u16, &ids);
34113411
lib/compiler/resinator/source_mapping.zig+1-1
...@@ -214,7 +214,7 @@ pub fn handleLineEnd(allocator: Allocator, post_processed_line_number: usize, ma...@@ -214,7 +214,7 @@ pub fn handleLineEnd(allocator: Allocator, post_processed_line_number: usize, ma
214// TODO: Might want to provide diagnostics on invalid line commands instead of just returning214// TODO: Might want to provide diagnostics on invalid line commands instead of just returning
215pub fn handleLineCommand(allocator: Allocator, line_command: []const u8, current_mapping: *CurrentMapping) error{OutOfMemory}!void {215pub fn handleLineCommand(allocator: Allocator, line_command: []const u8, current_mapping: *CurrentMapping) error{OutOfMemory}!void {
216 // TODO: Are there other whitespace characters that should be included?216 // TODO: Are there other whitespace characters that should be included?
217 var tokenizer = std.mem.tokenize(u8, line_command, " \t");217 var tokenizer = std.mem.tokenizeAny(u8, line_command, " \t");
218 const line_directive = tokenizer.next() orelse return; // #line218 const line_directive = tokenizer.next() orelse return; // #line
219 if (!std.mem.eql(u8, line_directive, "#line")) return;219 if (!std.mem.eql(u8, line_directive, "#line")) return;
220 const linenum_str = tokenizer.next() orelse return;220 const linenum_str = tokenizer.next() orelse return;
lib/docs/wasm/main.zig+1-1
...@@ -1212,7 +1212,7 @@ fn unindent(s: []const u8, indent: usize) []const u8 {...@@ -1212,7 +1212,7 @@ fn unindent(s: []const u8, indent: usize) []const u8 {
1212}1212}
12131213
1214fn appendUnindented(out: *std.ArrayListUnmanaged(u8), s: []const u8, indent: usize) !void {1214fn appendUnindented(out: *std.ArrayListUnmanaged(u8), s: []const u8, indent: usize) !void {
1215 var it = std.mem.split(u8, s, "\n");1215 var it = std.mem.splitScalar(u8, s, '\n');
1216 var is_first_line = true;1216 var is_first_line = true;
1217 while (it.next()) |line| {1217 while (it.next()) |line| {
1218 if (is_first_line) {1218 if (is_first_line) {
lib/docs/wasm/markdown.zig+1-1
...@@ -1112,7 +1112,7 @@ fn testRender(input: []const u8, expected: []const u8) !void {...@@ -1112,7 +1112,7 @@ fn testRender(input: []const u8, expected: []const u8) !void {
1112 var parser = try Parser.init(testing.allocator);1112 var parser = try Parser.init(testing.allocator);
1113 defer parser.deinit();1113 defer parser.deinit();
11141114
1115 var lines = std.mem.split(u8, input, "\n");1115 var lines = std.mem.splitScalar(u8, input, '\n');
1116 while (lines.next()) |line| {1116 while (lines.next()) |line| {
1117 try parser.feedLine(line);1117 try parser.feedLine(line);
1118 }1118 }
lib/std/Build/Cache/Path.zig+6-6
...@@ -49,7 +49,7 @@ pub fn openFile(...@@ -49,7 +49,7 @@ pub fn openFile(
49 sub_path: []const u8,49 sub_path: []const u8,
50 flags: fs.File.OpenFlags,50 flags: fs.File.OpenFlags,
51) !fs.File {51) !fs.File {
52 var buf: [fs.MAX_PATH_BYTES]u8 = undefined;52 var buf: [fs.max_path_bytes]u8 = undefined;
53 const joined_path = if (p.sub_path.len == 0) sub_path else p: {53 const joined_path = if (p.sub_path.len == 0) sub_path else p: {
54 break :p std.fmt.bufPrint(&buf, "{s}" ++ fs.path.sep_str ++ "{s}", .{54 break :p std.fmt.bufPrint(&buf, "{s}" ++ fs.path.sep_str ++ "{s}", .{
55 p.sub_path, sub_path,55 p.sub_path, sub_path,
...@@ -59,7 +59,7 @@ pub fn openFile(...@@ -59,7 +59,7 @@ pub fn openFile(
59}59}
6060
61pub fn makeOpenPath(p: Path, sub_path: []const u8, opts: fs.OpenDirOptions) !fs.Dir {61pub fn makeOpenPath(p: Path, sub_path: []const u8, opts: fs.OpenDirOptions) !fs.Dir {
62 var buf: [fs.MAX_PATH_BYTES]u8 = undefined;62 var buf: [fs.max_path_bytes]u8 = undefined;
63 const joined_path = if (p.sub_path.len == 0) sub_path else p: {63 const joined_path = if (p.sub_path.len == 0) sub_path else p: {
64 break :p std.fmt.bufPrint(&buf, "{s}" ++ fs.path.sep_str ++ "{s}", .{64 break :p std.fmt.bufPrint(&buf, "{s}" ++ fs.path.sep_str ++ "{s}", .{
65 p.sub_path, sub_path,65 p.sub_path, sub_path,
...@@ -69,7 +69,7 @@ pub fn makeOpenPath(p: Path, sub_path: []const u8, opts: fs.OpenDirOptions) !fs....@@ -69,7 +69,7 @@ pub fn makeOpenPath(p: Path, sub_path: []const u8, opts: fs.OpenDirOptions) !fs.
69}69}
7070
71pub fn statFile(p: Path, sub_path: []const u8) !fs.Dir.Stat {71pub fn statFile(p: Path, sub_path: []const u8) !fs.Dir.Stat {
72 var buf: [fs.MAX_PATH_BYTES]u8 = undefined;72 var buf: [fs.max_path_bytes]u8 = undefined;
73 const joined_path = if (p.sub_path.len == 0) sub_path else p: {73 const joined_path = if (p.sub_path.len == 0) sub_path else p: {
74 break :p std.fmt.bufPrint(&buf, "{s}" ++ fs.path.sep_str ++ "{s}", .{74 break :p std.fmt.bufPrint(&buf, "{s}" ++ fs.path.sep_str ++ "{s}", .{
75 p.sub_path, sub_path,75 p.sub_path, sub_path,
...@@ -82,7 +82,7 @@ pub fn atomicFile(...@@ -82,7 +82,7 @@ pub fn atomicFile(
82 p: Path,82 p: Path,
83 sub_path: []const u8,83 sub_path: []const u8,
84 options: fs.Dir.AtomicFileOptions,84 options: fs.Dir.AtomicFileOptions,
85 buf: *[fs.MAX_PATH_BYTES]u8,85 buf: *[fs.max_path_bytes]u8,
86) !fs.AtomicFile {86) !fs.AtomicFile {
87 const joined_path = if (p.sub_path.len == 0) sub_path else p: {87 const joined_path = if (p.sub_path.len == 0) sub_path else p: {
88 break :p std.fmt.bufPrint(buf, "{s}" ++ fs.path.sep_str ++ "{s}", .{88 break :p std.fmt.bufPrint(buf, "{s}" ++ fs.path.sep_str ++ "{s}", .{
...@@ -93,7 +93,7 @@ pub fn atomicFile(...@@ -93,7 +93,7 @@ pub fn atomicFile(
93}93}
9494
95pub fn access(p: Path, sub_path: []const u8, flags: fs.File.OpenFlags) !void {95pub fn access(p: Path, sub_path: []const u8, flags: fs.File.OpenFlags) !void {
96 var buf: [fs.MAX_PATH_BYTES]u8 = undefined;96 var buf: [fs.max_path_bytes]u8 = undefined;
97 const joined_path = if (p.sub_path.len == 0) sub_path else p: {97 const joined_path = if (p.sub_path.len == 0) sub_path else p: {
98 break :p std.fmt.bufPrint(&buf, "{s}" ++ fs.path.sep_str ++ "{s}", .{98 break :p std.fmt.bufPrint(&buf, "{s}" ++ fs.path.sep_str ++ "{s}", .{
99 p.sub_path, sub_path,99 p.sub_path, sub_path,
...@@ -103,7 +103,7 @@ pub fn access(p: Path, sub_path: []const u8, flags: fs.File.OpenFlags) !void {...@@ -103,7 +103,7 @@ pub fn access(p: Path, sub_path: []const u8, flags: fs.File.OpenFlags) !void {
103}103}
104104
105pub fn makePath(p: Path, sub_path: []const u8) !void {105pub fn makePath(p: Path, sub_path: []const u8) !void {
106 var buf: [fs.MAX_PATH_BYTES]u8 = undefined;106 var buf: [fs.max_path_bytes]u8 = undefined;
107 const joined_path = if (p.sub_path.len == 0) sub_path else p: {107 const joined_path = if (p.sub_path.len == 0) sub_path else p: {
108 break :p std.fmt.bufPrint(&buf, "{s}" ++ fs.path.sep_str ++ "{s}", .{108 break :p std.fmt.bufPrint(&buf, "{s}" ++ fs.path.sep_str ++ "{s}", .{
109 p.sub_path, sub_path,109 p.sub_path, sub_path,
lib/std/Random.zig+1-1
...@@ -9,7 +9,7 @@ const math = std.math;...@@ -9,7 +9,7 @@ const math = std.math;
9const mem = std.mem;9const mem = std.mem;
10const assert = std.debug.assert;10const assert = std.debug.assert;
11const maxInt = std.math.maxInt;11const maxInt = std.math.maxInt;
12pub const Random = @This(); // Remove pub when `std.rand` namespace is removed.12const Random = @This();
1313
14/// Fast unbiased random numbers.14/// Fast unbiased random numbers.
15pub const DefaultPrng = Xoshiro256;15pub const DefaultPrng = Xoshiro256;
lib/std/debug.zig+1-1
...@@ -1298,7 +1298,7 @@ pub fn readElfDebugInfo(...@@ -1298,7 +1298,7 @@ pub fn readElfDebugInfo(
1298 if (readElfDebugInfo(allocator, path, null, separate_debug_crc, &sections, mapped_mem)) |debug_info| return debug_info else |_| {}1298 if (readElfDebugInfo(allocator, path, null, separate_debug_crc, &sections, mapped_mem)) |debug_info| return debug_info else |_| {}
1299 }1299 }
13001300
1301 var cwd_buf: [fs.MAX_PATH_BYTES]u8 = undefined;1301 var cwd_buf: [fs.max_path_bytes]u8 = undefined;
1302 const cwd_path = posix.realpath(".", &cwd_buf) catch break :blk;1302 const cwd_path = posix.realpath(".", &cwd_buf) catch break :blk;
13031303
1304 // <global debug directory>/<absolute folder of current binary>/<gnu_debuglink>1304 // <global debug directory>/<absolute folder of current binary>/<gnu_debuglink>
lib/std/fs.zig+18-19
...@@ -35,8 +35,7 @@ pub const realpathW = posix.realpathW;...@@ -35,8 +35,7 @@ pub const realpathW = posix.realpathW;
35pub const getAppDataDir = @import("fs/get_app_data_dir.zig").getAppDataDir;35pub const getAppDataDir = @import("fs/get_app_data_dir.zig").getAppDataDir;
36pub const GetAppDataDirError = @import("fs/get_app_data_dir.zig").GetAppDataDirError;36pub const GetAppDataDirError = @import("fs/get_app_data_dir.zig").GetAppDataDirError;
3737
38/// Deprecated: use `max_path_bytes`.38pub const MAX_PATH_BYTES = @compileError("deprecated; renamed to max_path_bytes");
39pub const MAX_PATH_BYTES = max_path_bytes;
4039
41/// The maximum length of a file path that the operating system will accept.40/// The maximum length of a file path that the operating system will accept.
42///41///
...@@ -417,20 +416,20 @@ pub fn deleteTreeAbsolute(absolute_path: []const u8) !void {...@@ -417,20 +416,20 @@ pub fn deleteTreeAbsolute(absolute_path: []const u8) !void {
417/// On Windows, `pathname` should be encoded as [WTF-8](https://simonsapin.github.io/wtf-8/).416/// On Windows, `pathname` should be encoded as [WTF-8](https://simonsapin.github.io/wtf-8/).
418/// On WASI, `pathname` should be encoded as valid UTF-8.417/// On WASI, `pathname` should be encoded as valid UTF-8.
419/// On other platforms, `pathname` is an opaque sequence of bytes with no particular encoding.418/// On other platforms, `pathname` is an opaque sequence of bytes with no particular encoding.
420pub fn readLinkAbsolute(pathname: []const u8, buffer: *[MAX_PATH_BYTES]u8) ![]u8 {419pub fn readLinkAbsolute(pathname: []const u8, buffer: *[max_path_bytes]u8) ![]u8 {
421 assert(path.isAbsolute(pathname));420 assert(path.isAbsolute(pathname));
422 return posix.readlink(pathname, buffer);421 return posix.readlink(pathname, buffer);
423}422}
424423
425/// Windows-only. Same as `readlinkW`, except the path parameter is null-terminated, WTF16424/// Windows-only. Same as `readlinkW`, except the path parameter is null-terminated, WTF16
426/// encoded.425/// encoded.
427pub fn readlinkAbsoluteW(pathname_w: [*:0]const u16, buffer: *[MAX_PATH_BYTES]u8) ![]u8 {426pub fn readlinkAbsoluteW(pathname_w: [*:0]const u16, buffer: *[max_path_bytes]u8) ![]u8 {
428 assert(path.isAbsoluteWindowsW(pathname_w));427 assert(path.isAbsoluteWindowsW(pathname_w));
429 return posix.readlinkW(pathname_w, buffer);428 return posix.readlinkW(pathname_w, buffer);
430}429}
431430
432/// Same as `readLink`, except the path parameter is null-terminated.431/// Same as `readLink`, except the path parameter is null-terminated.
433pub fn readLinkAbsoluteZ(pathname_c: [*:0]const u8, buffer: *[MAX_PATH_BYTES]u8) ![]u8 {432pub fn readLinkAbsoluteZ(pathname_c: [*:0]const u8, buffer: *[max_path_bytes]u8) ![]u8 {
434 assert(path.isAbsoluteZ(pathname_c));433 assert(path.isAbsoluteZ(pathname_c));
435 return posix.readlinkZ(pathname_c, buffer);434 return posix.readlinkZ(pathname_c, buffer);
436}435}
...@@ -504,9 +503,9 @@ pub fn openSelfExe(flags: File.OpenFlags) OpenSelfExeError!File {...@@ -504,9 +503,9 @@ pub fn openSelfExe(flags: File.OpenFlags) OpenSelfExeError!File {
504 const prefixed_path_w = try windows.wToPrefixedFileW(null, image_path_name);503 const prefixed_path_w = try windows.wToPrefixedFileW(null, image_path_name);
505 return cwd().openFileW(prefixed_path_w.span(), flags);504 return cwd().openFileW(prefixed_path_w.span(), flags);
506 }505 }
507 // Use of MAX_PATH_BYTES here is valid as the resulting path is immediately506 // Use of max_path_bytes here is valid as the resulting path is immediately
508 // opened with no modification.507 // opened with no modification.
509 var buf: [MAX_PATH_BYTES]u8 = undefined;508 var buf: [max_path_bytes]u8 = undefined;
510 const self_exe_path = try selfExePath(&buf);509 const self_exe_path = try selfExePath(&buf);
511 buf[self_exe_path.len] = 0;510 buf[self_exe_path.len] = 0;
512 return openFileAbsoluteZ(buf[0..self_exe_path.len :0].ptr, flags);511 return openFileAbsoluteZ(buf[0..self_exe_path.len :0].ptr, flags);
...@@ -554,14 +553,14 @@ pub const SelfExePathError = error{...@@ -554,14 +553,14 @@ pub const SelfExePathError = error{
554/// `selfExePath` except allocates the result on the heap.553/// `selfExePath` except allocates the result on the heap.
555/// Caller owns returned memory.554/// Caller owns returned memory.
556pub fn selfExePathAlloc(allocator: Allocator) ![]u8 {555pub fn selfExePathAlloc(allocator: Allocator) ![]u8 {
557 // Use of MAX_PATH_BYTES here is justified as, at least on one tested Linux556 // Use of max_path_bytes here is justified as, at least on one tested Linux
558 // system, readlink will completely fail to return a result larger than557 // system, readlink will completely fail to return a result larger than
559 // PATH_MAX even if given a sufficiently large buffer. This makes it558 // PATH_MAX even if given a sufficiently large buffer. This makes it
560 // fundamentally impossible to get the selfExePath of a program running in559 // fundamentally impossible to get the selfExePath of a program running in
561 // a very deeply nested directory chain in this way.560 // a very deeply nested directory chain in this way.
562 // TODO(#4812): Investigate other systems and whether it is possible to get561 // TODO(#4812): Investigate other systems and whether it is possible to get
563 // this path by trying larger and larger buffers until one succeeds.562 // this path by trying larger and larger buffers until one succeeds.
564 var buf: [MAX_PATH_BYTES]u8 = undefined;563 var buf: [max_path_bytes]u8 = undefined;
565 return allocator.dupe(u8, try selfExePath(&buf));564 return allocator.dupe(u8, try selfExePath(&buf));
566}565}
567566
...@@ -581,12 +580,12 @@ pub fn selfExePath(out_buffer: []u8) SelfExePathError![]u8 {...@@ -581,12 +580,12 @@ pub fn selfExePath(out_buffer: []u8) SelfExePathError![]u8 {
581 if (is_darwin) {580 if (is_darwin) {
582 // Note that _NSGetExecutablePath() will return "a path" to581 // Note that _NSGetExecutablePath() will return "a path" to
583 // the executable not a "real path" to the executable.582 // the executable not a "real path" to the executable.
584 var symlink_path_buf: [MAX_PATH_BYTES:0]u8 = undefined;583 var symlink_path_buf: [max_path_bytes:0]u8 = undefined;
585 var u32_len: u32 = MAX_PATH_BYTES + 1; // include the sentinel584 var u32_len: u32 = max_path_bytes + 1; // include the sentinel
586 const rc = std.c._NSGetExecutablePath(&symlink_path_buf, &u32_len);585 const rc = std.c._NSGetExecutablePath(&symlink_path_buf, &u32_len);
587 if (rc != 0) return error.NameTooLong;586 if (rc != 0) return error.NameTooLong;
588587
589 var real_path_buf: [MAX_PATH_BYTES]u8 = undefined;588 var real_path_buf: [max_path_bytes]u8 = undefined;
590 const real_path = std.posix.realpathZ(&symlink_path_buf, &real_path_buf) catch |err| switch (err) {589 const real_path = std.posix.realpathZ(&symlink_path_buf, &real_path_buf) catch |err| switch (err) {
591 error.InvalidWtf8 => unreachable, // Windows-only590 error.InvalidWtf8 => unreachable, // Windows-only
592 error.NetworkNotFound => unreachable, // Windows-only591 error.NetworkNotFound => unreachable, // Windows-only
...@@ -634,7 +633,7 @@ pub fn selfExePath(out_buffer: []u8) SelfExePathError![]u8 {...@@ -634,7 +633,7 @@ pub fn selfExePath(out_buffer: []u8) SelfExePathError![]u8 {
634 const argv0 = mem.span(std.os.argv[0]);633 const argv0 = mem.span(std.os.argv[0]);
635 if (mem.indexOf(u8, argv0, "/") != null) {634 if (mem.indexOf(u8, argv0, "/") != null) {
636 // argv[0] is a path (relative or absolute): use realpath(3) directly635 // argv[0] is a path (relative or absolute): use realpath(3) directly
637 var real_path_buf: [MAX_PATH_BYTES]u8 = undefined;636 var real_path_buf: [max_path_bytes]u8 = undefined;
638 const real_path = posix.realpathZ(std.os.argv[0], &real_path_buf) catch |err| switch (err) {637 const real_path = posix.realpathZ(std.os.argv[0], &real_path_buf) catch |err| switch (err) {
639 error.InvalidWtf8 => unreachable, // Windows-only638 error.InvalidWtf8 => unreachable, // Windows-only
640 error.NetworkNotFound => unreachable, // Windows-only639 error.NetworkNotFound => unreachable, // Windows-only
...@@ -650,13 +649,13 @@ pub fn selfExePath(out_buffer: []u8) SelfExePathError![]u8 {...@@ -650,13 +649,13 @@ pub fn selfExePath(out_buffer: []u8) SelfExePathError![]u8 {
650 const PATH = posix.getenvZ("PATH") orelse return error.FileNotFound;649 const PATH = posix.getenvZ("PATH") orelse return error.FileNotFound;
651 var path_it = mem.tokenizeScalar(u8, PATH, path.delimiter);650 var path_it = mem.tokenizeScalar(u8, PATH, path.delimiter);
652 while (path_it.next()) |a_path| {651 while (path_it.next()) |a_path| {
653 var resolved_path_buf: [MAX_PATH_BYTES - 1:0]u8 = undefined;652 var resolved_path_buf: [max_path_bytes - 1:0]u8 = undefined;
654 const resolved_path = std.fmt.bufPrintZ(&resolved_path_buf, "{s}/{s}", .{653 const resolved_path = std.fmt.bufPrintZ(&resolved_path_buf, "{s}/{s}", .{
655 a_path,654 a_path,
656 std.os.argv[0],655 std.os.argv[0],
657 }) catch continue;656 }) catch continue;
658657
659 var real_path_buf: [MAX_PATH_BYTES]u8 = undefined;658 var real_path_buf: [max_path_bytes]u8 = undefined;
660 if (posix.realpathZ(resolved_path, &real_path_buf)) |real_path| {659 if (posix.realpathZ(resolved_path, &real_path_buf)) |real_path| {
661 // found a file, and hope it is the right file660 // found a file, and hope it is the right file
662 if (real_path.len > out_buffer.len)661 if (real_path.len > out_buffer.len)
...@@ -689,14 +688,14 @@ pub fn selfExePath(out_buffer: []u8) SelfExePathError![]u8 {...@@ -689,14 +688,14 @@ pub fn selfExePath(out_buffer: []u8) SelfExePathError![]u8 {
689/// `selfExeDirPath` except allocates the result on the heap.688/// `selfExeDirPath` except allocates the result on the heap.
690/// Caller owns returned memory.689/// Caller owns returned memory.
691pub fn selfExeDirPathAlloc(allocator: Allocator) ![]u8 {690pub fn selfExeDirPathAlloc(allocator: Allocator) ![]u8 {
692 // Use of MAX_PATH_BYTES here is justified as, at least on one tested Linux691 // Use of max_path_bytes here is justified as, at least on one tested Linux
693 // system, readlink will completely fail to return a result larger than692 // system, readlink will completely fail to return a result larger than
694 // PATH_MAX even if given a sufficiently large buffer. This makes it693 // PATH_MAX even if given a sufficiently large buffer. This makes it
695 // fundamentally impossible to get the selfExeDirPath of a program running694 // fundamentally impossible to get the selfExeDirPath of a program running
696 // in a very deeply nested directory chain in this way.695 // in a very deeply nested directory chain in this way.
697 // TODO(#4812): Investigate other systems and whether it is possible to get696 // TODO(#4812): Investigate other systems and whether it is possible to get
698 // this path by trying larger and larger buffers until one succeeds.697 // this path by trying larger and larger buffers until one succeeds.
699 var buf: [MAX_PATH_BYTES]u8 = undefined;698 var buf: [max_path_bytes]u8 = undefined;
700 return allocator.dupe(u8, try selfExeDirPath(&buf));699 return allocator.dupe(u8, try selfExeDirPath(&buf));
701}700}
702701
...@@ -716,13 +715,13 @@ pub fn selfExeDirPath(out_buffer: []u8) SelfExePathError![]const u8 {...@@ -716,13 +715,13 @@ pub fn selfExeDirPath(out_buffer: []u8) SelfExePathError![]const u8 {
716/// On other platforms, the result is an opaque sequence of bytes with no particular encoding.715/// On other platforms, the result is an opaque sequence of bytes with no particular encoding.
717/// See also `Dir.realpath`.716/// See also `Dir.realpath`.
718pub fn realpathAlloc(allocator: Allocator, pathname: []const u8) ![]u8 {717pub fn realpathAlloc(allocator: Allocator, pathname: []const u8) ![]u8 {
719 // Use of MAX_PATH_BYTES here is valid as the realpath function does not718 // Use of max_path_bytes here is valid as the realpath function does not
720 // have a variant that takes an arbitrary-size buffer.719 // have a variant that takes an arbitrary-size buffer.
721 // TODO(#4812): Consider reimplementing realpath or using the POSIX.1-2008720 // TODO(#4812): Consider reimplementing realpath or using the POSIX.1-2008
722 // NULL out parameter (GNU's canonicalize_file_name) to handle overelong721 // NULL out parameter (GNU's canonicalize_file_name) to handle overelong
723 // paths. musl supports passing NULL but restricts the output to PATH_MAX722 // paths. musl supports passing NULL but restricts the output to PATH_MAX
724 // anyway.723 // anyway.
725 var buf: [MAX_PATH_BYTES]u8 = undefined;724 var buf: [max_path_bytes]u8 = undefined;
726 return allocator.dupe(u8, try posix.realpath(pathname, &buf));725 return allocator.dupe(u8, try posix.realpath(pathname, &buf));
727}726}
728727
lib/std/fs/Dir.zig+6-6
...@@ -1309,7 +1309,7 @@ pub fn realpathZ(self: Dir, pathname: [*:0]const u8, out_buffer: []u8) RealPathE...@@ -1309,7 +1309,7 @@ pub fn realpathZ(self: Dir, pathname: [*:0]const u8, out_buffer: []u8) RealPathE
1309 };1309 };
1310 defer posix.close(fd);1310 defer posix.close(fd);
13111311
1312 var buffer: [fs.MAX_PATH_BYTES]u8 = undefined;1312 var buffer: [fs.max_path_bytes]u8 = undefined;
1313 const out_path = try std.os.getFdPath(fd, &buffer);1313 const out_path = try std.os.getFdPath(fd, &buffer);
13141314
1315 if (out_path.len > out_buffer.len) {1315 if (out_path.len > out_buffer.len) {
...@@ -1347,7 +1347,7 @@ pub fn realpathW(self: Dir, pathname: []const u16, out_buffer: []u8) RealPathErr...@@ -1347,7 +1347,7 @@ pub fn realpathW(self: Dir, pathname: []const u16, out_buffer: []u8) RealPathErr
13471347
1348 var wide_buf: [w.PATH_MAX_WIDE]u16 = undefined;1348 var wide_buf: [w.PATH_MAX_WIDE]u16 = undefined;
1349 const wide_slice = try w.GetFinalPathNameByHandle(h_file, .{}, &wide_buf);1349 const wide_slice = try w.GetFinalPathNameByHandle(h_file, .{}, &wide_buf);
1350 var big_out_buf: [fs.MAX_PATH_BYTES]u8 = undefined;1350 var big_out_buf: [fs.max_path_bytes]u8 = undefined;
1351 const end_index = std.unicode.wtf16LeToWtf8(&big_out_buf, wide_slice);1351 const end_index = std.unicode.wtf16LeToWtf8(&big_out_buf, wide_slice);
1352 if (end_index > out_buffer.len)1352 if (end_index > out_buffer.len)
1353 return error.NameTooLong;1353 return error.NameTooLong;
...@@ -1361,13 +1361,13 @@ pub const RealPathAllocError = RealPathError || Allocator.Error;...@@ -1361,13 +1361,13 @@ pub const RealPathAllocError = RealPathError || Allocator.Error;
1361/// Same as `Dir.realpath` except caller must free the returned memory.1361/// Same as `Dir.realpath` except caller must free the returned memory.
1362/// See also `Dir.realpath`.1362/// See also `Dir.realpath`.
1363pub fn realpathAlloc(self: Dir, allocator: Allocator, pathname: []const u8) RealPathAllocError![]u8 {1363pub fn realpathAlloc(self: Dir, allocator: Allocator, pathname: []const u8) RealPathAllocError![]u8 {
1364 // Use of MAX_PATH_BYTES here is valid as the realpath function does not1364 // Use of max_path_bytes here is valid as the realpath function does not
1365 // have a variant that takes an arbitrary-size buffer.1365 // have a variant that takes an arbitrary-size buffer.
1366 // TODO(#4812): Consider reimplementing realpath or using the POSIX.1-20081366 // TODO(#4812): Consider reimplementing realpath or using the POSIX.1-2008
1367 // NULL out parameter (GNU's canonicalize_file_name) to handle overelong1367 // NULL out parameter (GNU's canonicalize_file_name) to handle overelong
1368 // paths. musl supports passing NULL but restricts the output to PATH_MAX1368 // paths. musl supports passing NULL but restricts the output to PATH_MAX
1369 // anyway.1369 // anyway.
1370 var buf: [fs.MAX_PATH_BYTES]u8 = undefined;1370 var buf: [fs.max_path_bytes]u8 = undefined;
1371 return allocator.dupe(u8, try self.realpath(pathname, buf[0..]));1371 return allocator.dupe(u8, try self.realpath(pathname, buf[0..]));
1372}1372}
13731373
...@@ -2192,10 +2192,10 @@ fn deleteTreeMinStackSizeWithKindHint(self: Dir, sub_path: []const u8, kind_hint...@@ -2192,10 +2192,10 @@ fn deleteTreeMinStackSizeWithKindHint(self: Dir, sub_path: []const u8, kind_hint
2192 var cleanup_dir = true;2192 var cleanup_dir = true;
2193 defer if (cleanup_dir) dir.close();2193 defer if (cleanup_dir) dir.close();
21942194
2195 // Valid use of MAX_PATH_BYTES because dir_name_buf will only2195 // Valid use of max_path_bytes because dir_name_buf will only
2196 // ever store a single path component that was returned from the2196 // ever store a single path component that was returned from the
2197 // filesystem.2197 // filesystem.
2198 var dir_name_buf: [fs.MAX_PATH_BYTES]u8 = undefined;2198 var dir_name_buf: [fs.max_path_bytes]u8 = undefined;
2199 var dir_name: []const u8 = sub_path;2199 var dir_name: []const u8 = sub_path;
22002200
2201 // Here we must avoid recursion, in order to provide O(1) memory guarantee of this function.2201 // Here we must avoid recursion, in order to provide O(1) memory guarantee of this function.
lib/std/fs/get_app_data_dir.zig+1-1
...@@ -42,7 +42,7 @@ pub fn getAppDataDir(allocator: mem.Allocator, appname: []const u8) GetAppDataDi...@@ -42,7 +42,7 @@ pub fn getAppDataDir(allocator: mem.Allocator, appname: []const u8) GetAppDataDi
42 return fs.path.join(allocator, &[_][]const u8{ home_dir, ".local", "share", appname });42 return fs.path.join(allocator, &[_][]const u8{ home_dir, ".local", "share", appname });
43 },43 },
44 .haiku => {44 .haiku => {
45 var dir_path_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;45 var dir_path_buf: [std.fs.max_path_bytes]u8 = undefined;
46 const rc = std.c.find_directory(.B_USER_SETTINGS_DIRECTORY, -1, true, &dir_path_buf, dir_path_buf.len);46 const rc = std.c.find_directory(.B_USER_SETTINGS_DIRECTORY, -1, true, &dir_path_buf, dir_path_buf.len);
47 const settings_dir = try allocator.dupeZ(u8, mem.sliceTo(&dir_path_buf, 0));47 const settings_dir = try allocator.dupeZ(u8, mem.sliceTo(&dir_path_buf, 0));
48 defer allocator.free(settings_dir);48 defer allocator.free(settings_dir);
lib/std/fs/test.zig+7-7
...@@ -43,7 +43,7 @@ const PathType = enum {...@@ -43,7 +43,7 @@ const PathType = enum {
43 fn transform(allocator: mem.Allocator, dir: Dir, relative_path: [:0]const u8) TransformError![:0]const u8 {43 fn transform(allocator: mem.Allocator, dir: Dir, relative_path: [:0]const u8) TransformError![:0]const u8 {
44 // The final path may not actually exist which would cause realpath to fail.44 // The final path may not actually exist which would cause realpath to fail.
45 // So instead, we get the path of the dir and join it with the relative path.45 // So instead, we get the path of the dir and join it with the relative path.
46 var fd_path_buf: [fs.MAX_PATH_BYTES]u8 = undefined;46 var fd_path_buf: [fs.max_path_bytes]u8 = undefined;
47 const dir_path = try std.os.getFdPath(dir.fd, &fd_path_buf);47 const dir_path = try std.os.getFdPath(dir.fd, &fd_path_buf);
48 return fs.path.joinZ(allocator, &.{ dir_path, relative_path });48 return fs.path.joinZ(allocator, &.{ dir_path, relative_path });
49 }49 }
...@@ -52,7 +52,7 @@ const PathType = enum {...@@ -52,7 +52,7 @@ const PathType = enum {
52 fn transform(allocator: mem.Allocator, dir: Dir, relative_path: [:0]const u8) TransformError![:0]const u8 {52 fn transform(allocator: mem.Allocator, dir: Dir, relative_path: [:0]const u8) TransformError![:0]const u8 {
53 // Any drive absolute path (C:\foo) can be converted into a UNC path by53 // Any drive absolute path (C:\foo) can be converted into a UNC path by
54 // using '127.0.0.1' as the server name and '<drive letter>$' as the share name.54 // using '127.0.0.1' as the server name and '<drive letter>$' as the share name.
55 var fd_path_buf: [fs.MAX_PATH_BYTES]u8 = undefined;55 var fd_path_buf: [fs.max_path_bytes]u8 = undefined;
56 const dir_path = try std.os.getFdPath(dir.fd, &fd_path_buf);56 const dir_path = try std.os.getFdPath(dir.fd, &fd_path_buf);
57 const windows_path_type = windows.getUnprefixedPathType(u8, dir_path);57 const windows_path_type = windows.getUnprefixedPathType(u8, dir_path);
58 switch (windows_path_type) {58 switch (windows_path_type) {
...@@ -206,13 +206,13 @@ test "Dir.readLink" {...@@ -206,13 +206,13 @@ test "Dir.readLink" {
206}206}
207207
208fn testReadLink(dir: Dir, target_path: []const u8, symlink_path: []const u8) !void {208fn testReadLink(dir: Dir, target_path: []const u8, symlink_path: []const u8) !void {
209 var buffer: [fs.MAX_PATH_BYTES]u8 = undefined;209 var buffer: [fs.max_path_bytes]u8 = undefined;
210 const actual = try dir.readLink(symlink_path, buffer[0..]);210 const actual = try dir.readLink(symlink_path, buffer[0..]);
211 try testing.expectEqualStrings(target_path, actual);211 try testing.expectEqualStrings(target_path, actual);
212}212}
213213
214fn testReadLinkAbsolute(target_path: []const u8, symlink_path: []const u8) !void {214fn testReadLinkAbsolute(target_path: []const u8, symlink_path: []const u8) !void {
215 var buffer: [fs.MAX_PATH_BYTES]u8 = undefined;215 var buffer: [fs.max_path_bytes]u8 = undefined;
216 const given = try fs.readLinkAbsolute(symlink_path, buffer[0..]);216 const given = try fs.readLinkAbsolute(symlink_path, buffer[0..]);
217 try testing.expectEqualStrings(target_path, given);217 try testing.expectEqualStrings(target_path, given);
218}218}
...@@ -611,7 +611,7 @@ test "Dir.realpath smoke test" {...@@ -611,7 +611,7 @@ test "Dir.realpath smoke test" {
611 const allocator = ctx.arena.allocator();611 const allocator = ctx.arena.allocator();
612 const test_file_path = try ctx.transformPath("test_file");612 const test_file_path = try ctx.transformPath("test_file");
613 const test_dir_path = try ctx.transformPath("test_dir");613 const test_dir_path = try ctx.transformPath("test_dir");
614 var buf: [fs.MAX_PATH_BYTES]u8 = undefined;614 var buf: [fs.max_path_bytes]u8 = undefined;
615615
616 // FileNotFound if the path doesn't exist616 // FileNotFound if the path doesn't exist
617 try testing.expectError(error.FileNotFound, ctx.dir.realpathAlloc(allocator, test_file_path));617 try testing.expectError(error.FileNotFound, ctx.dir.realpathAlloc(allocator, test_file_path));
...@@ -1041,7 +1041,7 @@ test "openSelfExe" {...@@ -1041,7 +1041,7 @@ test "openSelfExe" {
1041test "selfExePath" {1041test "selfExePath" {
1042 if (native_os == .wasi) return error.SkipZigTest;1042 if (native_os == .wasi) return error.SkipZigTest;
10431043
1044 var buf: [fs.MAX_PATH_BYTES]u8 = undefined;1044 var buf: [fs.max_path_bytes]u8 = undefined;
1045 const buf_self_exe_path = try std.fs.selfExePath(&buf);1045 const buf_self_exe_path = try std.fs.selfExePath(&buf);
1046 const alloc_self_exe_path = try std.fs.selfExePathAlloc(testing.allocator);1046 const alloc_self_exe_path = try std.fs.selfExePathAlloc(testing.allocator);
1047 defer testing.allocator.free(alloc_self_exe_path);1047 defer testing.allocator.free(alloc_self_exe_path);
...@@ -2061,7 +2061,7 @@ test "invalid UTF-8/WTF-8 paths" {...@@ -2061,7 +2061,7 @@ test "invalid UTF-8/WTF-8 paths" {
2061 try testing.expectError(expected_err, fs.deleteFileAbsolute(invalid_path));2061 try testing.expectError(expected_err, fs.deleteFileAbsolute(invalid_path));
2062 try testing.expectError(expected_err, fs.deleteFileAbsoluteZ(invalid_path));2062 try testing.expectError(expected_err, fs.deleteFileAbsoluteZ(invalid_path));
2063 try testing.expectError(expected_err, fs.deleteTreeAbsolute(invalid_path));2063 try testing.expectError(expected_err, fs.deleteTreeAbsolute(invalid_path));
2064 var readlink_buf: [fs.MAX_PATH_BYTES]u8 = undefined;2064 var readlink_buf: [fs.max_path_bytes]u8 = undefined;
2065 try testing.expectError(expected_err, fs.readLinkAbsolute(invalid_path, &readlink_buf));2065 try testing.expectError(expected_err, fs.readLinkAbsolute(invalid_path, &readlink_buf));
2066 try testing.expectError(expected_err, fs.readLinkAbsoluteZ(invalid_path, &readlink_buf));2066 try testing.expectError(expected_err, fs.readLinkAbsoluteZ(invalid_path, &readlink_buf));
2067 try testing.expectError(expected_err, fs.symLinkAbsolute(invalid_path, invalid_path, .{}));2067 try testing.expectError(expected_err, fs.symLinkAbsolute(invalid_path, invalid_path, .{}));
lib/std/mem.zig+3-6
...@@ -2083,8 +2083,7 @@ test byteSwapAllFields {...@@ -2083,8 +2083,7 @@ test byteSwapAllFields {
2083 }, k);2083 }, k);
2084}2084}
20852085
2086/// Deprecated: use `tokenizeAny`, `tokenizeSequence`, or `tokenizeScalar`2086pub const tokenize = @compileError("deprecated; use tokenizeAny, tokenizeSequence, or tokenizeScalar");
2087pub const tokenize = tokenizeAny;
20882087
2089/// Returns an iterator that iterates over the slices of `buffer` that are not2088/// Returns an iterator that iterates over the slices of `buffer` that are not
2090/// any of the items in `delimiters`.2089/// any of the items in `delimiters`.
...@@ -2284,8 +2283,7 @@ test "tokenize (reset)" {...@@ -2284,8 +2283,7 @@ test "tokenize (reset)" {
2284 }2283 }
2285}2284}
22862285
2287/// Deprecated: use `splitSequence`, `splitAny`, or `splitScalar`2286pub const split = @compileError("deprecated; use splitSequence, splitAny, or splitScalar");
2288pub const split = splitSequence;
22892287
2290/// Returns an iterator that iterates over the slices of `buffer` that2288/// Returns an iterator that iterates over the slices of `buffer` that
2291/// are separated by the byte sequence in `delimiter`.2289/// are separated by the byte sequence in `delimiter`.
...@@ -2486,8 +2484,7 @@ test "split (reset)" {...@@ -2486,8 +2484,7 @@ test "split (reset)" {
2486 }2484 }
2487}2485}
24882486
2489/// Deprecated: use `splitBackwardsSequence`, `splitBackwardsAny`, or `splitBackwardsScalar`2487pub const splitBackwards = @compileError("deprecated; use splitBackwardsSequence, splitBackwardsAny, or splitBackwardsScalar");
2490pub const splitBackwards = splitBackwardsSequence;
24912488
2492/// Returns an iterator that iterates backwards over the slices of `buffer` that2489/// Returns an iterator that iterates backwards over the slices of `buffer` that
2493/// are separated by the sequence in `delimiter`.2490/// are separated by the sequence in `delimiter`.
lib/std/os.zig+10-10
...@@ -21,7 +21,7 @@ const mem = std.mem;...@@ -21,7 +21,7 @@ const mem = std.mem;
21const elf = std.elf;21const elf = std.elf;
22const fs = std.fs;22const fs = std.fs;
23const dl = @import("dynamic_library.zig");23const dl = @import("dynamic_library.zig");
24const MAX_PATH_BYTES = std.fs.MAX_PATH_BYTES;24const max_path_bytes = std.fs.max_path_bytes;
25const posix = std.posix;25const posix = std.posix;
2626
27pub const linux = @import("os/linux.zig");27pub const linux = @import("os/linux.zig");
...@@ -99,7 +99,7 @@ pub fn isGetFdPathSupportedOnTarget(os: std.Target.Os) bool {...@@ -99,7 +99,7 @@ pub fn isGetFdPathSupportedOnTarget(os: std.Target.Os) bool {
99/// * On other platforms, the result is an opaque sequence of bytes with no particular encoding.99/// * On other platforms, the result is an opaque sequence of bytes with no particular encoding.
100///100///
101/// Calling this function is usually a bug.101/// Calling this function is usually a bug.
102pub fn getFdPath(fd: std.posix.fd_t, out_buffer: *[MAX_PATH_BYTES]u8) std.posix.RealPathError![]u8 {102pub fn getFdPath(fd: std.posix.fd_t, out_buffer: *[max_path_bytes]u8) std.posix.RealPathError![]u8 {
103 if (!comptime isGetFdPathSupportedOnTarget(builtin.os)) {103 if (!comptime isGetFdPathSupportedOnTarget(builtin.os)) {
104 @compileError("querying for canonical path of a handle is unsupported on this host");104 @compileError("querying for canonical path of a handle is unsupported on this host");
105 }105 }
...@@ -114,7 +114,7 @@ pub fn getFdPath(fd: std.posix.fd_t, out_buffer: *[MAX_PATH_BYTES]u8) std.posix....@@ -114,7 +114,7 @@ pub fn getFdPath(fd: std.posix.fd_t, out_buffer: *[MAX_PATH_BYTES]u8) std.posix.
114 .macos, .ios, .watchos, .tvos, .visionos => {114 .macos, .ios, .watchos, .tvos, .visionos => {
115 // On macOS, we can use F.GETPATH fcntl command to query the OS for115 // On macOS, we can use F.GETPATH fcntl command to query the OS for
116 // the path to the file descriptor.116 // the path to the file descriptor.
117 @memset(out_buffer[0..MAX_PATH_BYTES], 0);117 @memset(out_buffer[0..max_path_bytes], 0);
118 switch (posix.errno(posix.system.fcntl(fd, posix.F.GETPATH, out_buffer))) {118 switch (posix.errno(posix.system.fcntl(fd, posix.F.GETPATH, out_buffer))) {
119 .SUCCESS => {},119 .SUCCESS => {},
120 .BADF => return error.FileNotFound,120 .BADF => return error.FileNotFound,
...@@ -123,7 +123,7 @@ pub fn getFdPath(fd: std.posix.fd_t, out_buffer: *[MAX_PATH_BYTES]u8) std.posix....@@ -123,7 +123,7 @@ pub fn getFdPath(fd: std.posix.fd_t, out_buffer: *[MAX_PATH_BYTES]u8) std.posix.
123 // errno values to expect when command is F.GETPATH...123 // errno values to expect when command is F.GETPATH...
124 else => |err| return posix.unexpectedErrno(err),124 else => |err| return posix.unexpectedErrno(err),
125 }125 }
126 const len = mem.indexOfScalar(u8, out_buffer[0..], 0) orelse MAX_PATH_BYTES;126 const len = mem.indexOfScalar(u8, out_buffer[0..], 0) orelse max_path_bytes;
127 return out_buffer[0..len];127 return out_buffer[0..len];
128 },128 },
129 .linux => {129 .linux => {
...@@ -163,7 +163,7 @@ pub fn getFdPath(fd: std.posix.fd_t, out_buffer: *[MAX_PATH_BYTES]u8) std.posix....@@ -163,7 +163,7 @@ pub fn getFdPath(fd: std.posix.fd_t, out_buffer: *[MAX_PATH_BYTES]u8) std.posix.
163 .BADF => return error.FileNotFound,163 .BADF => return error.FileNotFound,
164 else => |err| return posix.unexpectedErrno(err),164 else => |err| return posix.unexpectedErrno(err),
165 }165 }
166 const len = mem.indexOfScalar(u8, &kfile.path, 0) orelse MAX_PATH_BYTES;166 const len = mem.indexOfScalar(u8, &kfile.path, 0) orelse max_path_bytes;
167 if (len == 0) return error.NameTooLong;167 if (len == 0) return error.NameTooLong;
168 const result = out_buffer[0..len];168 const result = out_buffer[0..len];
169 @memcpy(result, kfile.path[0..len]);169 @memcpy(result, kfile.path[0..len]);
...@@ -196,7 +196,7 @@ pub fn getFdPath(fd: std.posix.fd_t, out_buffer: *[MAX_PATH_BYTES]u8) std.posix....@@ -196,7 +196,7 @@ pub fn getFdPath(fd: std.posix.fd_t, out_buffer: *[MAX_PATH_BYTES]u8) std.posix.
196 while (i < len) {196 while (i < len) {
197 const kf: *align(1) std.c.kinfo_file = @ptrCast(&buf[i]);197 const kf: *align(1) std.c.kinfo_file = @ptrCast(&buf[i]);
198 if (kf.fd == fd) {198 if (kf.fd == fd) {
199 len = mem.indexOfScalar(u8, &kf.path, 0) orelse MAX_PATH_BYTES;199 len = mem.indexOfScalar(u8, &kf.path, 0) orelse max_path_bytes;
200 if (len == 0) return error.NameTooLong;200 if (len == 0) return error.NameTooLong;
201 const result = out_buffer[0..len];201 const result = out_buffer[0..len];
202 @memcpy(result, kf.path[0..len]);202 @memcpy(result, kf.path[0..len]);
...@@ -208,18 +208,18 @@ pub fn getFdPath(fd: std.posix.fd_t, out_buffer: *[MAX_PATH_BYTES]u8) std.posix....@@ -208,18 +208,18 @@ pub fn getFdPath(fd: std.posix.fd_t, out_buffer: *[MAX_PATH_BYTES]u8) std.posix.
208 }208 }
209 },209 },
210 .dragonfly => {210 .dragonfly => {
211 @memset(out_buffer[0..MAX_PATH_BYTES], 0);211 @memset(out_buffer[0..max_path_bytes], 0);
212 switch (posix.errno(std.c.fcntl(fd, posix.F.GETPATH, out_buffer))) {212 switch (posix.errno(std.c.fcntl(fd, posix.F.GETPATH, out_buffer))) {
213 .SUCCESS => {},213 .SUCCESS => {},
214 .BADF => return error.FileNotFound,214 .BADF => return error.FileNotFound,
215 .RANGE => return error.NameTooLong,215 .RANGE => return error.NameTooLong,
216 else => |err| return posix.unexpectedErrno(err),216 else => |err| return posix.unexpectedErrno(err),
217 }217 }
218 const len = mem.indexOfScalar(u8, out_buffer[0..], 0) orelse MAX_PATH_BYTES;218 const len = mem.indexOfScalar(u8, out_buffer[0..], 0) orelse max_path_bytes;
219 return out_buffer[0..len];219 return out_buffer[0..len];
220 },220 },
221 .netbsd => {221 .netbsd => {
222 @memset(out_buffer[0..MAX_PATH_BYTES], 0);222 @memset(out_buffer[0..max_path_bytes], 0);
223 switch (posix.errno(std.c.fcntl(fd, posix.F.GETPATH, out_buffer))) {223 switch (posix.errno(std.c.fcntl(fd, posix.F.GETPATH, out_buffer))) {
224 .SUCCESS => {},224 .SUCCESS => {},
225 .ACCES => return error.AccessDenied,225 .ACCES => return error.AccessDenied,
...@@ -229,7 +229,7 @@ pub fn getFdPath(fd: std.posix.fd_t, out_buffer: *[MAX_PATH_BYTES]u8) std.posix....@@ -229,7 +229,7 @@ pub fn getFdPath(fd: std.posix.fd_t, out_buffer: *[MAX_PATH_BYTES]u8) std.posix.
229 .RANGE => return error.NameTooLong,229 .RANGE => return error.NameTooLong,
230 else => |err| return posix.unexpectedErrno(err),230 else => |err| return posix.unexpectedErrno(err),
231 }231 }
232 const len = mem.indexOfScalar(u8, out_buffer[0..], 0) orelse MAX_PATH_BYTES;232 const len = mem.indexOfScalar(u8, out_buffer[0..], 0) orelse max_path_bytes;
233 return out_buffer[0..len];233 return out_buffer[0..len];
234 },234 },
235 else => unreachable, // made unreachable by isGetFdPathSupportedOnTarget above235 else => unreachable, // made unreachable by isGetFdPathSupportedOnTarget above
lib/std/os/linux/IoUring.zig+2-2
...@@ -3995,7 +3995,7 @@ test "ring mapped buffers recv" {...@@ -3995,7 +3995,7 @@ test "ring mapped buffers recv" {
3995 defer fds.close();3995 defer fds.close();
39963996
3997 // for random user_data in sqe/cqe3997 // for random user_data in sqe/cqe
3998 var Rnd = std.rand.DefaultPrng.init(0);3998 var Rnd = std.Random.DefaultPrng.init(0);
3999 var rnd = Rnd.random();3999 var rnd = Rnd.random();
40004000
4001 var round: usize = 4; // repeat send/recv cycle round times4001 var round: usize = 4; // repeat send/recv cycle round times
...@@ -4081,7 +4081,7 @@ test "ring mapped buffers multishot recv" {...@@ -4081,7 +4081,7 @@ test "ring mapped buffers multishot recv" {
4081 defer fds.close();4081 defer fds.close();
40824082
4083 // for random user_data in sqe/cqe4083 // for random user_data in sqe/cqe
4084 var Rnd = std.rand.DefaultPrng.init(0);4084 var Rnd = std.Random.DefaultPrng.init(0);
4085 var rnd = Rnd.random();4085 var rnd = Rnd.random();
40864086
4087 var round: usize = 4; // repeat send/recv cycle round times4087 var round: usize = 4; // repeat send/recv cycle round times
lib/std/os/plan9.zig+5-5
...@@ -285,16 +285,16 @@ pub fn openat(dirfd: i32, path: [*:0]const u8, flags: u32, _: mode_t) usize {...@@ -285,16 +285,16 @@ pub fn openat(dirfd: i32, path: [*:0]const u8, flags: u32, _: mode_t) usize {
285 if (dirfd == AT.FDCWD) { // openat(AT_FDCWD, ...) == open(...)285 if (dirfd == AT.FDCWD) { // openat(AT_FDCWD, ...) == open(...)
286 return open(path, flags);286 return open(path, flags);
287 }287 }
288 var dir_path_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;288 var dir_path_buf: [std.fs.max_path_bytes]u8 = undefined;
289 var total_path_buf: [std.fs.MAX_PATH_BYTES + 1]u8 = undefined;289 var total_path_buf: [std.fs.max_path_bytes + 1]u8 = undefined;
290 const rc = fd2path(dirfd, &dir_path_buf, std.fs.MAX_PATH_BYTES);290 const rc = fd2path(dirfd, &dir_path_buf, std.fs.max_path_bytes);
291 if (rc != 0) return rc;291 if (rc != 0) return rc;
292 var fba = std.heap.FixedBufferAllocator.init(&total_path_buf);292 var fba = std.heap.FixedBufferAllocator.init(&total_path_buf);
293 var alloc = fba.allocator();293 var alloc = fba.allocator();
294 const dir_path = std.mem.span(@as([*:0]u8, @ptrCast(&dir_path_buf)));294 const dir_path = std.mem.span(@as([*:0]u8, @ptrCast(&dir_path_buf)));
295 const total_path = std.fs.path.join(alloc, &.{ dir_path, std.mem.span(path) }) catch unreachable; // the allocation shouldn't fail because it should not exceed MAX_PATH_BYTES295 const total_path = std.fs.path.join(alloc, &.{ dir_path, std.mem.span(path) }) catch unreachable; // the allocation shouldn't fail because it should not exceed max_path_bytes
296 fba.reset();296 fba.reset();
297 const total_path_z = alloc.dupeZ(u8, total_path) catch unreachable; // should not exceed MAX_PATH_BYTES + 1297 const total_path_z = alloc.dupeZ(u8, total_path) catch unreachable; // should not exceed max_path_bytes + 1
298 return open(total_path_z.ptr, flags);298 return open(total_path_z.ptr, flags);
299}299}
300300
lib/std/os/windows/test.zig+2-2
...@@ -30,7 +30,7 @@ fn testToPrefixedFileNoOracle(comptime path: []const u8, comptime expected_path:...@@ -30,7 +30,7 @@ fn testToPrefixedFileNoOracle(comptime path: []const u8, comptime expected_path:
30 const expected_path_utf16 = std.unicode.utf8ToUtf16LeStringLiteral(expected_path);30 const expected_path_utf16 = std.unicode.utf8ToUtf16LeStringLiteral(expected_path);
31 const actual_path = try windows.wToPrefixedFileW(null, path_utf16);31 const actual_path = try windows.wToPrefixedFileW(null, path_utf16);
32 std.testing.expectEqualSlices(u16, expected_path_utf16, actual_path.span()) catch |e| {32 std.testing.expectEqualSlices(u16, expected_path_utf16, actual_path.span()) catch |e| {
33 std.debug.print("got '{s}', expected '{s}'\n", .{ std.unicode.fmtUtf16Le(actual_path.span()), std.unicode.fmtUtf16le(expected_path_utf16) });33 std.debug.print("got '{s}', expected '{s}'\n", .{ std.unicode.fmtUtf16Le(actual_path.span()), std.unicode.fmtUtf16Le(expected_path_utf16) });
34 return e;34 return e;
35 };35 };
36}36}
...@@ -48,7 +48,7 @@ fn testToPrefixedFileOnlyOracle(comptime path: []const u8) !void {...@@ -48,7 +48,7 @@ fn testToPrefixedFileOnlyOracle(comptime path: []const u8) !void {
48 const zig_result = try windows.wToPrefixedFileW(null, path_utf16);48 const zig_result = try windows.wToPrefixedFileW(null, path_utf16);
49 const win32_api_result = try RtlDosPathNameToNtPathName_U(path_utf16);49 const win32_api_result = try RtlDosPathNameToNtPathName_U(path_utf16);
50 std.testing.expectEqualSlices(u16, win32_api_result.span(), zig_result.span()) catch |e| {50 std.testing.expectEqualSlices(u16, win32_api_result.span(), zig_result.span()) catch |e| {
51 std.debug.print("got '{s}', expected '{s}'\n", .{ std.unicode.fmtUtf16Le(zig_result.span()), std.unicode.fmtUtf16le(win32_api_result.span()) });51 std.debug.print("got '{s}', expected '{s}'\n", .{ std.unicode.fmtUtf16Le(zig_result.span()), std.unicode.fmtUtf16Le(win32_api_result.span()) });
52 return e;52 return e;
53 };53 };
54}54}
lib/std/posix.zig+1-1
...@@ -19,7 +19,7 @@ const root = @import("root");...@@ -19,7 +19,7 @@ const root = @import("root");
19const std = @import("std.zig");19const std = @import("std.zig");
20const mem = std.mem;20const mem = std.mem;
21const fs = std.fs;21const fs = std.fs;
22const max_path_bytes = fs.MAX_PATH_BYTES;22const max_path_bytes = fs.max_path_bytes;
23const maxInt = std.math.maxInt;23const maxInt = std.math.maxInt;
24const cast = std.math.cast;24const cast = std.math.cast;
25const assert = std.debug.assert;25const assert = std.debug.assert;
lib/std/posix/test.zig+10-10
...@@ -31,13 +31,13 @@ test "chdir smoke test" {...@@ -31,13 +31,13 @@ test "chdir smoke test" {
31 }31 }
3232
33 // Get current working directory path33 // Get current working directory path
34 var old_cwd_buf: [fs.MAX_PATH_BYTES]u8 = undefined;34 var old_cwd_buf: [fs.max_path_bytes]u8 = undefined;
35 const old_cwd = try posix.getcwd(old_cwd_buf[0..]);35 const old_cwd = try posix.getcwd(old_cwd_buf[0..]);
3636
37 {37 {
38 // Firstly, changing to itself should have no effect38 // Firstly, changing to itself should have no effect
39 try posix.chdir(old_cwd);39 try posix.chdir(old_cwd);
40 var new_cwd_buf: [fs.MAX_PATH_BYTES]u8 = undefined;40 var new_cwd_buf: [fs.max_path_bytes]u8 = undefined;
41 const new_cwd = try posix.getcwd(new_cwd_buf[0..]);41 const new_cwd = try posix.getcwd(new_cwd_buf[0..]);
42 try expect(mem.eql(u8, old_cwd, new_cwd));42 try expect(mem.eql(u8, old_cwd, new_cwd));
43 }43 }
...@@ -50,7 +50,7 @@ test "chdir smoke test" {...@@ -50,7 +50,7 @@ test "chdir smoke test" {
50 // Restore cwd because process may have other tests that do not tolerate chdir.50 // Restore cwd because process may have other tests that do not tolerate chdir.
51 defer posix.chdir(old_cwd) catch unreachable;51 defer posix.chdir(old_cwd) catch unreachable;
5252
53 var new_cwd_buf: [fs.MAX_PATH_BYTES]u8 = undefined;53 var new_cwd_buf: [fs.max_path_bytes]u8 = undefined;
54 const new_cwd = try posix.getcwd(new_cwd_buf[0..]);54 const new_cwd = try posix.getcwd(new_cwd_buf[0..]);
55 try expect(mem.eql(u8, parent, new_cwd));55 try expect(mem.eql(u8, parent, new_cwd));
56 }56 }
...@@ -58,7 +58,7 @@ test "chdir smoke test" {...@@ -58,7 +58,7 @@ test "chdir smoke test" {
58 // Next, change current working directory to a temp directory one level below58 // Next, change current working directory to a temp directory one level below
59 {59 {
60 // Create a tmp directory60 // Create a tmp directory
61 var tmp_dir_buf: [fs.MAX_PATH_BYTES]u8 = undefined;61 var tmp_dir_buf: [fs.max_path_bytes]u8 = undefined;
62 const tmp_dir_path = path: {62 const tmp_dir_path = path: {
63 var allocator = std.heap.FixedBufferAllocator.init(&tmp_dir_buf);63 var allocator = std.heap.FixedBufferAllocator.init(&tmp_dir_buf);
64 break :path try fs.path.resolve(allocator.allocator(), &[_][]const u8{ old_cwd, "zig-test-tmp" });64 break :path try fs.path.resolve(allocator.allocator(), &[_][]const u8{ old_cwd, "zig-test-tmp" });
...@@ -68,11 +68,11 @@ test "chdir smoke test" {...@@ -68,11 +68,11 @@ test "chdir smoke test" {
68 // Change current working directory to tmp directory68 // Change current working directory to tmp directory
69 try posix.chdir("zig-test-tmp");69 try posix.chdir("zig-test-tmp");
7070
71 var new_cwd_buf: [fs.MAX_PATH_BYTES]u8 = undefined;71 var new_cwd_buf: [fs.max_path_bytes]u8 = undefined;
72 const new_cwd = try posix.getcwd(new_cwd_buf[0..]);72 const new_cwd = try posix.getcwd(new_cwd_buf[0..]);
7373
74 // On Windows, fs.path.resolve returns an uppercase drive letter, but the drive letter returned by getcwd may be lowercase74 // On Windows, fs.path.resolve returns an uppercase drive letter, but the drive letter returned by getcwd may be lowercase
75 var resolved_cwd_buf: [fs.MAX_PATH_BYTES]u8 = undefined;75 var resolved_cwd_buf: [fs.max_path_bytes]u8 = undefined;
76 const resolved_cwd = path: {76 const resolved_cwd = path: {
77 var allocator = std.heap.FixedBufferAllocator.init(&resolved_cwd_buf);77 var allocator = std.heap.FixedBufferAllocator.init(&resolved_cwd_buf);
78 break :path try fs.path.resolve(allocator.allocator(), &[_][]const u8{new_cwd});78 break :path try fs.path.resolve(allocator.allocator(), &[_][]const u8{new_cwd});
...@@ -230,7 +230,7 @@ test "symlink with relative paths" {...@@ -230,7 +230,7 @@ test "symlink with relative paths" {
230 try posix.symlink("file.txt", "symlinked");230 try posix.symlink("file.txt", "symlinked");
231 }231 }
232232
233 var buffer: [fs.MAX_PATH_BYTES]u8 = undefined;233 var buffer: [fs.max_path_bytes]u8 = undefined;
234 const given = try posix.readlink("symlinked", buffer[0..]);234 const given = try posix.readlink("symlinked", buffer[0..]);
235 try expect(mem.eql(u8, "file.txt", given));235 try expect(mem.eql(u8, "file.txt", given));
236236
...@@ -247,7 +247,7 @@ test "readlink on Windows" {...@@ -247,7 +247,7 @@ test "readlink on Windows" {
247}247}
248248
249fn testReadlink(target_path: []const u8, symlink_path: []const u8) !void {249fn testReadlink(target_path: []const u8, symlink_path: []const u8) !void {
250 var buffer: [fs.MAX_PATH_BYTES]u8 = undefined;250 var buffer: [fs.max_path_bytes]u8 = undefined;
251 const given = try posix.readlink(symlink_path, buffer[0..]);251 const given = try posix.readlink(symlink_path, buffer[0..]);
252 try expect(mem.eql(u8, target_path, given));252 try expect(mem.eql(u8, target_path, given));
253}253}
...@@ -385,7 +385,7 @@ test "readlinkat" {...@@ -385,7 +385,7 @@ test "readlinkat" {
385 }385 }
386386
387 // read the link387 // read the link
388 var buffer: [fs.MAX_PATH_BYTES]u8 = undefined;388 var buffer: [fs.max_path_bytes]u8 = undefined;
389 const read_link = try posix.readlinkat(tmp.dir.fd, "link", buffer[0..]);389 const read_link = try posix.readlinkat(tmp.dir.fd, "link", buffer[0..]);
390 try expect(mem.eql(u8, "file.txt", read_link));390 try expect(mem.eql(u8, "file.txt", read_link));
391}391}
...@@ -466,7 +466,7 @@ test "getrandom" {...@@ -466,7 +466,7 @@ test "getrandom" {
466466
467test "getcwd" {467test "getcwd" {
468 // at least call it so it gets compiled468 // at least call it so it gets compiled
469 var buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;469 var buf: [std.fs.max_path_bytes]u8 = undefined;
470 _ = posix.getcwd(&buf) catch undefined;470 _ = posix.getcwd(&buf) catch undefined;
471}471}
472472
lib/std/process.zig+3-3
...@@ -32,9 +32,9 @@ pub const GetCwdAllocError = Allocator.Error || posix.GetCwdError;...@@ -32,9 +32,9 @@ pub const GetCwdAllocError = Allocator.Error || posix.GetCwdError;
32/// On Windows, the result is encoded as [WTF-8](https://simonsapin.github.io/wtf-8/).32/// On Windows, the result is encoded as [WTF-8](https://simonsapin.github.io/wtf-8/).
33/// On other platforms, the result is an opaque sequence of bytes with no particular encoding.33/// On other platforms, the result is an opaque sequence of bytes with no particular encoding.
34pub fn getCwdAlloc(allocator: Allocator) ![]u8 {34pub fn getCwdAlloc(allocator: Allocator) ![]u8 {
35 // The use of MAX_PATH_BYTES here is just a heuristic: most paths will fit35 // The use of max_path_bytes here is just a heuristic: most paths will fit
36 // in stack_buf, avoiding an extra allocation in the common case.36 // in stack_buf, avoiding an extra allocation in the common case.
37 var stack_buf: [fs.MAX_PATH_BYTES]u8 = undefined;37 var stack_buf: [fs.max_path_bytes]u8 = undefined;
38 var heap_buf: ?[]u8 = null;38 var heap_buf: ?[]u8 = null;
39 defer if (heap_buf) |buf| allocator.free(buf);39 defer if (heap_buf) |buf| allocator.free(buf);
4040
...@@ -1618,7 +1618,7 @@ pub const can_execv = switch (native_os) {...@@ -1618,7 +1618,7 @@ pub const can_execv = switch (native_os) {
1618 else => true,1618 else => true,
1619};1619};
16201620
1621/// Tells whether spawning child processes is supported (e.g. via ChildProcess)1621/// Tells whether spawning child processes is supported (e.g. via Child)
1622pub const can_spawn = switch (native_os) {1622pub const can_spawn = switch (native_os) {
1623 .wasi, .watchos, .tvos, .visionos => false,1623 .wasi, .watchos, .tvos, .visionos => false,
1624 else => true,1624 else => true,
lib/std/std.zig-4
...@@ -43,8 +43,6 @@ pub const StringHashMap = hash_map.StringHashMap;...@@ -43,8 +43,6 @@ pub const StringHashMap = hash_map.StringHashMap;
43pub const StringHashMapUnmanaged = hash_map.StringHashMapUnmanaged;43pub const StringHashMapUnmanaged = hash_map.StringHashMapUnmanaged;
44pub const StringArrayHashMap = array_hash_map.StringArrayHashMap;44pub const StringArrayHashMap = array_hash_map.StringArrayHashMap;
45pub const StringArrayHashMapUnmanaged = array_hash_map.StringArrayHashMapUnmanaged;45pub const StringArrayHashMapUnmanaged = array_hash_map.StringArrayHashMapUnmanaged;
46/// deprecated: use `DoublyLinkedList`.
47pub const TailQueue = DoublyLinkedList;
48pub const Target = @import("Target.zig");46pub const Target = @import("Target.zig");
49pub const Thread = @import("Thread.zig");47pub const Thread = @import("Thread.zig");
50pub const Treap = @import("treap.zig").Treap;48pub const Treap = @import("treap.zig").Treap;
...@@ -88,8 +86,6 @@ pub const packed_int_array = @import("packed_int_array.zig");...@@ -88,8 +86,6 @@ pub const packed_int_array = @import("packed_int_array.zig");
88pub const pdb = @import("pdb.zig");86pub const pdb = @import("pdb.zig");
89pub const posix = @import("posix.zig");87pub const posix = @import("posix.zig");
90pub const process = @import("process.zig");88pub const process = @import("process.zig");
91/// Deprecated: use `Random` instead.
92pub const rand = Random;
93pub const sort = @import("sort.zig");89pub const sort = @import("sort.zig");
94pub const simd = @import("simd.zig");90pub const simd = @import("simd.zig");
95pub const ascii = @import("ascii.zig");91pub const ascii = @import("ascii.zig");
lib/std/tar.zig+6-6
...@@ -283,9 +283,9 @@ fn nullStr(str: []const u8) []const u8 {...@@ -283,9 +283,9 @@ fn nullStr(str: []const u8) []const u8 {
283/// Options for iterator.283/// Options for iterator.
284/// Buffers should be provided by the caller.284/// Buffers should be provided by the caller.
285pub const IteratorOptions = struct {285pub const IteratorOptions = struct {
286 /// Use a buffer with length `std.fs.MAX_PATH_BYTES` to match file system capabilities.286 /// Use a buffer with length `std.fs.max_path_bytes` to match file system capabilities.
287 file_name_buffer: []u8,287 file_name_buffer: []u8,
288 /// Use a buffer with length `std.fs.MAX_PATH_BYTES` to match file system capabilities.288 /// Use a buffer with length `std.fs.max_path_bytes` to match file system capabilities.
289 link_name_buffer: []u8,289 link_name_buffer: []u8,
290 /// Collects error messages during unpacking290 /// Collects error messages during unpacking
291 diagnostics: ?*Diagnostics = null,291 diagnostics: ?*Diagnostics = null,
...@@ -613,8 +613,8 @@ fn PaxIterator(comptime ReaderType: type) type {...@@ -613,8 +613,8 @@ fn PaxIterator(comptime ReaderType: type) type {
613613
614/// Saves tar file content to the file systems.614/// Saves tar file content to the file systems.
615pub fn pipeToFileSystem(dir: std.fs.Dir, reader: anytype, options: PipeOptions) !void {615pub fn pipeToFileSystem(dir: std.fs.Dir, reader: anytype, options: PipeOptions) !void {
616 var file_name_buffer: [std.fs.MAX_PATH_BYTES]u8 = undefined;616 var file_name_buffer: [std.fs.max_path_bytes]u8 = undefined;
617 var link_name_buffer: [std.fs.MAX_PATH_BYTES]u8 = undefined;617 var link_name_buffer: [std.fs.max_path_bytes]u8 = undefined;
618 var iter = iterator(reader, .{618 var iter = iterator(reader, .{
619 .file_name_buffer = &file_name_buffer,619 .file_name_buffer = &file_name_buffer,
620 .link_name_buffer = &link_name_buffer,620 .link_name_buffer = &link_name_buffer,
...@@ -946,8 +946,8 @@ test iterator {...@@ -946,8 +946,8 @@ test iterator {
946 var fbs = std.io.fixedBufferStream(data);946 var fbs = std.io.fixedBufferStream(data);
947947
948 // User provided buffers to the iterator948 // User provided buffers to the iterator
949 var file_name_buffer: [std.fs.MAX_PATH_BYTES]u8 = undefined;949 var file_name_buffer: [std.fs.max_path_bytes]u8 = undefined;
950 var link_name_buffer: [std.fs.MAX_PATH_BYTES]u8 = undefined;950 var link_name_buffer: [std.fs.max_path_bytes]u8 = undefined;
951 // Create iterator951 // Create iterator
952 var iter = iterator(fbs.reader(), .{952 var iter = iterator(fbs.reader(), .{
953 .file_name_buffer = &file_name_buffer,953 .file_name_buffer = &file_name_buffer,
lib/std/tar/test.zig+2-2
...@@ -342,8 +342,8 @@ const Md5Writer = struct {...@@ -342,8 +342,8 @@ const Md5Writer = struct {
342};342};
343343
344test "run test cases" {344test "run test cases" {
345 var file_name_buffer: [std.fs.MAX_PATH_BYTES]u8 = undefined;345 var file_name_buffer: [std.fs.max_path_bytes]u8 = undefined;
346 var link_name_buffer: [std.fs.MAX_PATH_BYTES]u8 = undefined;346 var link_name_buffer: [std.fs.max_path_bytes]u8 = undefined;
347347
348 for (cases) |case| {348 for (cases) |case| {
349 var fsb = std.io.fixedBufferStream(case.data);349 var fsb = std.io.fixedBufferStream(case.data);
lib/std/unicode.zig+6-11
...@@ -983,8 +983,7 @@ pub fn utf16LeToUtf8ArrayList(result: *std.ArrayList(u8), utf16le: []const u16)...@@ -983,8 +983,7 @@ pub fn utf16LeToUtf8ArrayList(result: *std.ArrayList(u8), utf16le: []const u16)
983 return utf16LeToUtf8ArrayListImpl(result, utf16le, .cannot_encode_surrogate_half);983 return utf16LeToUtf8ArrayListImpl(result, utf16le, .cannot_encode_surrogate_half);
984}984}
985985
986/// Deprecated; renamed to utf16LeToUtf8Alloc986pub const utf16leToUtf8Alloc = @compileError("deprecated; renamed to utf16LeToUtf8Alloc");
987pub const utf16leToUtf8Alloc = utf16LeToUtf8Alloc;
988987
989/// Caller must free returned memory.988/// Caller must free returned memory.
990pub fn utf16LeToUtf8Alloc(allocator: mem.Allocator, utf16le: []const u16) Utf16LeToUtf8AllocError![]u8 {989pub fn utf16LeToUtf8Alloc(allocator: mem.Allocator, utf16le: []const u16) Utf16LeToUtf8AllocError![]u8 {
...@@ -996,8 +995,7 @@ pub fn utf16LeToUtf8Alloc(allocator: mem.Allocator, utf16le: []const u16) Utf16L...@@ -996,8 +995,7 @@ pub fn utf16LeToUtf8Alloc(allocator: mem.Allocator, utf16le: []const u16) Utf16L
996 return result.toOwnedSlice();995 return result.toOwnedSlice();
997}996}
998997
999/// Deprecated; renamed to utf16LeToUtf8AllocZ998pub const utf16leToUtf8AllocZ = @compileError("deprecated; renamed to utf16LeToUtf8AllocZ");
1000pub const utf16leToUtf8AllocZ = utf16LeToUtf8AllocZ;
1001999
1002/// Caller must free returned memory.1000/// Caller must free returned memory.
1003pub fn utf16LeToUtf8AllocZ(allocator: mem.Allocator, utf16le: []const u16) Utf16LeToUtf8AllocError![:0]u8 {1001pub fn utf16LeToUtf8AllocZ(allocator: mem.Allocator, utf16le: []const u16) Utf16LeToUtf8AllocError![:0]u8 {
...@@ -1067,8 +1065,7 @@ fn utf16LeToUtf8Impl(utf8: []u8, utf16le: []const u16, comptime surrogates: Surr...@@ -1067,8 +1065,7 @@ fn utf16LeToUtf8Impl(utf8: []u8, utf16le: []const u16, comptime surrogates: Surr
1067 return dest_index;1065 return dest_index;
1068}1066}
10691067
1070/// Deprecated; renamed to utf16LeToUtf81068pub const utf16leToUtf8 = @compileError("deprecated; renamed to utf16LeToUtf8");
1071pub const utf16leToUtf8 = utf16LeToUtf8;
10721069
1073pub fn utf16LeToUtf8(utf8: []u8, utf16le: []const u16) Utf16LeToUtf8Error!usize {1070pub fn utf16LeToUtf8(utf8: []u8, utf16le: []const u16) Utf16LeToUtf8Error!usize {
1074 return utf16LeToUtf8Impl(utf8, utf16le, .cannot_encode_surrogate_half);1071 return utf16LeToUtf8Impl(utf8, utf16le, .cannot_encode_surrogate_half);
...@@ -1189,8 +1186,7 @@ pub fn utf8ToUtf16LeAlloc(allocator: mem.Allocator, utf8: []const u8) error{ Inv...@@ -1189,8 +1186,7 @@ pub fn utf8ToUtf16LeAlloc(allocator: mem.Allocator, utf8: []const u8) error{ Inv
1189 return result.toOwnedSlice();1186 return result.toOwnedSlice();
1190}1187}
11911188
1192/// Deprecated; renamed to utf8ToUtf16LeAllocZ1189pub const utf8ToUtf16LeWithNull = @compileError("deprecated; renamed to utf8ToUtf16LeAllocZ");
1193pub const utf8ToUtf16LeWithNull = utf8ToUtf16LeAllocZ;
11941190
1195pub fn utf8ToUtf16LeAllocZ(allocator: mem.Allocator, utf8: []const u8) error{ InvalidUtf8, OutOfMemory }![:0]u16 {1191pub fn utf8ToUtf16LeAllocZ(allocator: mem.Allocator, utf8: []const u8) error{ InvalidUtf8, OutOfMemory }![:0]u16 {
1196 // optimistically guess that it will not require surrogate pairs1192 // optimistically guess that it will not require surrogate pairs
...@@ -1335,7 +1331,7 @@ test utf8ToUtf16LeAllocZ {...@@ -1335,7 +1331,7 @@ test utf8ToUtf16LeAllocZ {
1335 try testing.expectError(error.InvalidUtf8, result);1331 try testing.expectError(error.InvalidUtf8, result);
1336 }1332 }
1337 {1333 {
1338 const utf16 = try utf8ToUtf16LeWithNull(testing.allocator, "This string has been designed to test the vectorized implementat" ++1334 const utf16 = try utf8ToUtf16LeAllocZ(testing.allocator, "This string has been designed to test the vectorized implementat" ++
1339 "ion by beginning with one hundred twenty-seven ASCII characters¡");1335 "ion by beginning with one hundred twenty-seven ASCII characters¡");
1340 defer testing.allocator.free(utf16);1336 defer testing.allocator.free(utf16);
1341 try testing.expectEqualSlices(u8, &.{1337 try testing.expectEqualSlices(u8, &.{
...@@ -1479,8 +1475,7 @@ fn formatUtf16Le(...@@ -1479,8 +1475,7 @@ fn formatUtf16Le(
1479 try writer.writeAll(buf[0..u8len]);1475 try writer.writeAll(buf[0..u8len]);
1480}1476}
14811477
1482/// Deprecated; renamed to fmtUtf16Le1478pub const fmtUtf16le = @compileError("deprecated; renamed to fmtUtf16Le");
1483pub const fmtUtf16le = fmtUtf16Le;
14841479
1485/// Return a Formatter for a (potentially ill-formed) UTF-16 LE string,1480/// Return a Formatter for a (potentially ill-formed) UTF-16 LE string,
1486/// which will be converted to UTF-8 during formatting.1481/// which will be converted to UTF-8 during formatting.
lib/std/zig.zig+1-2
...@@ -15,8 +15,7 @@ pub const Ast = @import("zig/Ast.zig");...@@ -15,8 +15,7 @@ pub const Ast = @import("zig/Ast.zig");
15pub const AstGen = @import("zig/AstGen.zig");15pub const AstGen = @import("zig/AstGen.zig");
16pub const Zir = @import("zig/Zir.zig");16pub const Zir = @import("zig/Zir.zig");
17pub const system = @import("zig/system.zig");17pub const system = @import("zig/system.zig");
18/// Deprecated: use `std.Target.Query`.18pub const CrossTarget = @compileError("deprecated; use std.Target.Query");
19pub const CrossTarget = std.Target.Query;
20pub const BuiltinFn = @import("zig/BuiltinFn.zig");19pub const BuiltinFn = @import("zig/BuiltinFn.zig");
21pub const AstRlAnnotate = @import("zig/AstRlAnnotate.zig");20pub const AstRlAnnotate = @import("zig/AstRlAnnotate.zig");
22pub const LibCInstallation = @import("zig/LibCInstallation.zig");21pub const LibCInstallation = @import("zig/LibCInstallation.zig");
lib/std/zig/WindowsSdk.zig+7-7
...@@ -444,7 +444,7 @@ pub const Installation = struct {...@@ -444,7 +444,7 @@ pub const Installation = struct {
444444
445 error.OutOfMemory => return error.OutOfMemory,445 error.OutOfMemory => return error.OutOfMemory,
446 };446 };
447 if (path_maybe_with_trailing_slash.len > std.fs.MAX_PATH_BYTES or !std.fs.path.isAbsolute(path_maybe_with_trailing_slash)) {447 if (path_maybe_with_trailing_slash.len > std.fs.max_path_bytes or !std.fs.path.isAbsolute(path_maybe_with_trailing_slash)) {
448 allocator.free(path_maybe_with_trailing_slash);448 allocator.free(path_maybe_with_trailing_slash);
449 return error.PathTooLong;449 return error.PathTooLong;
450 }450 }
...@@ -459,7 +459,7 @@ pub const Installation = struct {...@@ -459,7 +459,7 @@ pub const Installation = struct {
459 errdefer allocator.free(path);459 errdefer allocator.free(path);
460460
461 const version = version: {461 const version = version: {
462 var buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;462 var buf: [std.fs.max_path_bytes]u8 = undefined;
463 const sdk_lib_dir_path = std.fmt.bufPrint(buf[0..], "{s}\\Lib\\", .{path}) catch |err| switch (err) {463 const sdk_lib_dir_path = std.fmt.bufPrint(buf[0..], "{s}\\Lib\\", .{path}) catch |err| switch (err) {
464 error.NoSpaceLeft => return error.PathTooLong,464 error.NoSpaceLeft => return error.PathTooLong,
465 };465 };
...@@ -516,7 +516,7 @@ pub const Installation = struct {...@@ -516,7 +516,7 @@ pub const Installation = struct {
516 error.OutOfMemory => return error.OutOfMemory,516 error.OutOfMemory => return error.OutOfMemory,
517 };517 };
518518
519 if (path_maybe_with_trailing_slash.len > std.fs.MAX_PATH_BYTES or !std.fs.path.isAbsolute(path_maybe_with_trailing_slash)) {519 if (path_maybe_with_trailing_slash.len > std.fs.max_path_bytes or !std.fs.path.isAbsolute(path_maybe_with_trailing_slash)) {
520 allocator.free(path_maybe_with_trailing_slash);520 allocator.free(path_maybe_with_trailing_slash);
521 return error.PathTooLong;521 return error.PathTooLong;
522 }522 }
...@@ -562,7 +562,7 @@ pub const Installation = struct {...@@ -562,7 +562,7 @@ pub const Installation = struct {
562562
563 /// Check whether this version is enumerated in registry.563 /// Check whether this version is enumerated in registry.
564 fn isValidVersion(installation: Installation) bool {564 fn isValidVersion(installation: Installation) bool {
565 var buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;565 var buf: [std.fs.max_path_bytes]u8 = undefined;
566 const reg_query_as_wtf8 = std.fmt.bufPrint(buf[0..], "{s}\\{s}\\Installed Options", .{566 const reg_query_as_wtf8 = std.fmt.bufPrint(buf[0..], "{s}\\{s}\\Installed Options", .{
567 windows_kits_reg_key,567 windows_kits_reg_key,
568 installation.version,568 installation.version,
...@@ -878,7 +878,7 @@ const MsvcLibDir = struct {...@@ -878,7 +878,7 @@ const MsvcLibDir = struct {
878 error.OutOfMemory => return error.OutOfMemory,878 error.OutOfMemory => return error.OutOfMemory,
879 else => continue,879 else => continue,
880 };880 };
881 if (source_directories_value.len > (std.fs.MAX_PATH_BYTES * 30)) { // note(bratishkaerik): guessing from the fact that on my computer it has 15 pathes and at least some of them are not of max length881 if (source_directories_value.len > (std.fs.max_path_bytes * 30)) { // note(bratishkaerik): guessing from the fact that on my computer it has 15 pathes and at least some of them are not of max length
882 allocator.free(source_directories_value);882 allocator.free(source_directories_value);
883 continue;883 continue;
884 }884 }
...@@ -892,7 +892,7 @@ const MsvcLibDir = struct {...@@ -892,7 +892,7 @@ const MsvcLibDir = struct {
892 const msvc_dir: []const u8 = msvc_dir: {892 const msvc_dir: []const u8 = msvc_dir: {
893 const msvc_include_dir_maybe_with_trailing_slash = try allocator.dupe(u8, source_directories_splitted.first());893 const msvc_include_dir_maybe_with_trailing_slash = try allocator.dupe(u8, source_directories_splitted.first());
894894
895 if (msvc_include_dir_maybe_with_trailing_slash.len > std.fs.MAX_PATH_BYTES or !std.fs.path.isAbsolute(msvc_include_dir_maybe_with_trailing_slash)) {895 if (msvc_include_dir_maybe_with_trailing_slash.len > std.fs.max_path_bytes or !std.fs.path.isAbsolute(msvc_include_dir_maybe_with_trailing_slash)) {
896 allocator.free(msvc_include_dir_maybe_with_trailing_slash);896 allocator.free(msvc_include_dir_maybe_with_trailing_slash);
897 return error.PathNotFound;897 return error.PathNotFound;
898 }898 }
...@@ -960,7 +960,7 @@ const MsvcLibDir = struct {...@@ -960,7 +960,7 @@ const MsvcLibDir = struct {
960 else => break :try_vs7_key,960 else => break :try_vs7_key,
961 };961 };
962962
963 if (path_maybe_with_trailing_slash.len > std.fs.MAX_PATH_BYTES or !std.fs.path.isAbsolute(path_maybe_with_trailing_slash)) {963 if (path_maybe_with_trailing_slash.len > std.fs.max_path_bytes or !std.fs.path.isAbsolute(path_maybe_with_trailing_slash)) {
964 allocator.free(path_maybe_with_trailing_slash);964 allocator.free(path_maybe_with_trailing_slash);
965 break :try_vs7_key;965 break :try_vs7_key;
966 }966 }
lib/std/zip.zig+1-1
...@@ -583,7 +583,7 @@ pub fn extract(dest: std.fs.Dir, seekable_stream: anytype, options: ExtractOptio...@@ -583,7 +583,7 @@ pub fn extract(dest: std.fs.Dir, seekable_stream: anytype, options: ExtractOptio
583 const SeekableStream = @TypeOf(seekable_stream);583 const SeekableStream = @TypeOf(seekable_stream);
584 var iter = try Iterator(SeekableStream).init(seekable_stream);584 var iter = try Iterator(SeekableStream).init(seekable_stream);
585585
586 var filename_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;586 var filename_buf: [std.fs.max_path_bytes]u8 = undefined;
587 while (try iter.next()) |entry| {587 while (try iter.next()) |entry| {
588 const crc32 = try entry.extract(seekable_stream, options, &filename_buf, dest);588 const crc32 = try entry.extract(seekable_stream, options, &filename_buf, dest);
589 if (crc32 != entry.crc32)589 if (crc32 != entry.crc32)
lib/std/zip/test.zig+1-1
...@@ -17,7 +17,7 @@ pub fn expectFiles(...@@ -17,7 +17,7 @@ pub fn expectFiles(
17 },17 },
18) !void {18) !void {
19 for (test_files) |test_file| {19 for (test_files) |test_file| {
20 var normalized_sub_path_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;20 var normalized_sub_path_buf: [std.fs.max_path_bytes]u8 = undefined;
2121
22 const name = blk: {22 const name = blk: {
23 if (opt.strip_prefix) |strip_prefix| {23 if (opt.strip_prefix) |strip_prefix| {
src/Builtin.zig+1-1
...@@ -266,7 +266,7 @@ pub fn populateFile(comp: *Compilation, mod: *Module, file: *File) !void {...@@ -266,7 +266,7 @@ pub fn populateFile(comp: *Compilation, mod: *Module, file: *File) !void {
266}266}
267267
268fn writeFile(file: *File, mod: *Module) !void {268fn writeFile(file: *File, mod: *Module) !void {
269 var buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;269 var buf: [std.fs.max_path_bytes]u8 = undefined;
270 var af = try mod.root.atomicFile(mod.root_src_path, .{ .make_path = true }, &buf);270 var af = try mod.root.atomicFile(mod.root_src_path, .{ .make_path = true }, &buf);
271 defer af.deinit();271 defer af.deinit();
272 try af.file.writeAll(file.source);272 try af.file.writeAll(file.source);
src/Package/Fetch.zig+2-2
...@@ -1364,7 +1364,7 @@ fn recursiveDirectoryCopy(f: *Fetch, dir: fs.Dir, tmp_dir: fs.Dir) anyerror!void...@@ -1364,7 +1364,7 @@ fn recursiveDirectoryCopy(f: *Fetch, dir: fs.Dir, tmp_dir: fs.Dir) anyerror!void
1364 };1364 };
1365 },1365 },
1366 .sym_link => {1366 .sym_link => {
1367 var buf: [fs.MAX_PATH_BYTES]u8 = undefined;1367 var buf: [fs.max_path_bytes]u8 = undefined;
1368 const link_name = try dir.readLink(entry.path, &buf);1368 const link_name = try dir.readLink(entry.path, &buf);
1369 // TODO: if this would create a symlink to outside1369 // TODO: if this would create a symlink to outside
1370 // the destination directory, fail with an error instead.1370 // the destination directory, fail with an error instead.
...@@ -1748,7 +1748,7 @@ pub fn depDigest(...@@ -1748,7 +1748,7 @@ pub fn depDigest(
1748 switch (dep.location) {1748 switch (dep.location) {
1749 .url => return null,1749 .url => return null,
1750 .path => |rel_path| {1750 .path => |rel_path| {
1751 var buf: [fs.MAX_PATH_BYTES]u8 = undefined;1751 var buf: [fs.max_path_bytes]u8 = undefined;
1752 var fba = std.heap.FixedBufferAllocator.init(&buf);1752 var fba = std.heap.FixedBufferAllocator.init(&buf);
1753 const new_root = pkg_root.resolvePosix(fba.allocator(), rel_path) catch1753 const new_root = pkg_root.resolvePosix(fba.allocator(), rel_path) catch
1754 return null;1754 return null;
src/codegen/llvm.zig+1-1
...@@ -1975,7 +1975,7 @@ pub const Object = struct {...@@ -1975,7 +1975,7 @@ pub const Object = struct {
1975 defer gpa.free(dir_path);1975 defer gpa.free(dir_path);
1976 if (std.fs.path.isAbsolute(dir_path))1976 if (std.fs.path.isAbsolute(dir_path))
1977 break :dir_path try o.builder.metadataString(dir_path);1977 break :dir_path try o.builder.metadataString(dir_path);
1978 var abs_buffer: [std.fs.MAX_PATH_BYTES]u8 = undefined;1978 var abs_buffer: [std.fs.max_path_bytes]u8 = undefined;
1979 const abs_path = std.fs.realpath(dir_path, &abs_buffer) catch1979 const abs_path = std.fs.realpath(dir_path, &abs_buffer) catch
1980 break :dir_path try o.builder.metadataString(dir_path);1980 break :dir_path try o.builder.metadataString(dir_path);
1981 break :dir_path try o.builder.metadataString(abs_path);1981 break :dir_path try o.builder.metadataString(abs_path);
src/link/Dwarf.zig+3-3
...@@ -2006,7 +2006,7 @@ pub fn writeDbgInfoHeader(self: *Dwarf, zcu: *Module, low_pc: u64, high_pc: u64)...@@ -2006,7 +2006,7 @@ pub fn writeDbgInfoHeader(self: *Dwarf, zcu: *Module, low_pc: u64, high_pc: u64)
20062006
2007 // Write the form for the compile unit, which must match the abbrev table above.2007 // Write the form for the compile unit, which must match the abbrev table above.
2008 const name_strp = try self.strtab.insert(self.allocator, zcu.root_mod.root_src_path);2008 const name_strp = try self.strtab.insert(self.allocator, zcu.root_mod.root_src_path);
2009 var compile_unit_dir_buffer: [std.fs.MAX_PATH_BYTES]u8 = undefined;2009 var compile_unit_dir_buffer: [std.fs.max_path_bytes]u8 = undefined;
2010 const compile_unit_dir = resolveCompilationDir(zcu, &compile_unit_dir_buffer);2010 const compile_unit_dir = resolveCompilationDir(zcu, &compile_unit_dir_buffer);
2011 const comp_dir_strp = try self.strtab.insert(self.allocator, compile_unit_dir);2011 const comp_dir_strp = try self.strtab.insert(self.allocator, compile_unit_dir);
2012 const producer_strp = try self.strtab.insert(self.allocator, link.producer_string);2012 const producer_strp = try self.strtab.insert(self.allocator, link.producer_string);
...@@ -2058,7 +2058,7 @@ pub fn writeDbgInfoHeader(self: *Dwarf, zcu: *Module, low_pc: u64, high_pc: u64)...@@ -2058,7 +2058,7 @@ pub fn writeDbgInfoHeader(self: *Dwarf, zcu: *Module, low_pc: u64, high_pc: u64)
2058 }2058 }
2059}2059}
20602060
2061fn resolveCompilationDir(module: *Module, buffer: *[std.fs.MAX_PATH_BYTES]u8) []const u8 {2061fn resolveCompilationDir(module: *Module, buffer: *[std.fs.max_path_bytes]u8) []const u8 {
2062 // We fully resolve all paths at this point to avoid lack of source line info in stack2062 // We fully resolve all paths at this point to avoid lack of source line info in stack
2063 // traces or lack of debugging information which, if relative paths were used, would2063 // traces or lack of debugging information which, if relative paths were used, would
2064 // be very location dependent.2064 // be very location dependent.
...@@ -2804,7 +2804,7 @@ fn genIncludeDirsAndFileNames(self: *Dwarf, arena: Allocator) !struct {...@@ -2804,7 +2804,7 @@ fn genIncludeDirsAndFileNames(self: *Dwarf, arena: Allocator) !struct {
2804 const dir_path = std.fs.path.dirname(full_path) orelse ".";2804 const dir_path = std.fs.path.dirname(full_path) orelse ".";
2805 const sub_file_path = std.fs.path.basename(full_path);2805 const sub_file_path = std.fs.path.basename(full_path);
2806 // https://github.com/ziglang/zig/issues/193532806 // https://github.com/ziglang/zig/issues/19353
2807 var buffer: [std.fs.MAX_PATH_BYTES]u8 = undefined;2807 var buffer: [std.fs.max_path_bytes]u8 = undefined;
2808 const resolved = if (!std.fs.path.isAbsolute(dir_path))2808 const resolved = if (!std.fs.path.isAbsolute(dir_path))
2809 std.posix.realpath(dir_path, &buffer) catch dir_path2809 std.posix.realpath(dir_path, &buffer) catch dir_path
2810 else2810 else
src/link/Elf.zig+2-2
...@@ -1831,7 +1831,7 @@ fn parseLdScript(self: *Elf, lib: SystemLib) ParseError!void {...@@ -1831,7 +1831,7 @@ fn parseLdScript(self: *Elf, lib: SystemLib) ParseError!void {
1831 break :success;1831 break :success;
1832 }1832 }
1833 } else {1833 } else {
1834 var buffer: [fs.MAX_PATH_BYTES]u8 = undefined;1834 var buffer: [fs.max_path_bytes]u8 = undefined;
1835 if (fs.realpath(scr_obj.path, &buffer)) |path| {1835 if (fs.realpath(scr_obj.path, &buffer)) |path| {
1836 test_path.clearRetainingCapacity();1836 test_path.clearRetainingCapacity();
1837 try test_path.writer().writeAll(path);1837 try test_path.writer().writeAll(path);
...@@ -3706,7 +3706,7 @@ fn sortInitFini(self: *Elf) !void {...@@ -3706,7 +3706,7 @@ fn sortInitFini(self: *Elf) !void {
3706 }3706 }
3707 const default: i32 = if (is_ctor_dtor) -1 else std.math.maxInt(i32);3707 const default: i32 = if (is_ctor_dtor) -1 else std.math.maxInt(i32);
3708 const name = atom_ptr.name(self);3708 const name = atom_ptr.name(self);
3709 var it = mem.splitBackwards(u8, name, ".");3709 var it = mem.splitBackwardsScalar(u8, name, '.');
3710 const priority = std.fmt.parseUnsigned(u16, it.first(), 10) catch default;3710 const priority = std.fmt.parseUnsigned(u16, it.first(), 10) catch default;
3711 break :blk priority;3711 break :blk priority;
3712 };3712 };
src/link/MachO.zig+2-2
...@@ -1230,7 +1230,7 @@ fn parseDependentDylibs(self: *MachO) !void {...@@ -1230,7 +1230,7 @@ fn parseDependentDylibs(self: *MachO) !void {
1230 const prefix = eatPrefix(rpath, "@loader_path/") orelse rpath;1230 const prefix = eatPrefix(rpath, "@loader_path/") orelse rpath;
1231 const rel_path = try fs.path.join(arena, &.{ prefix, path });1231 const rel_path = try fs.path.join(arena, &.{ prefix, path });
1232 try checked_paths.append(rel_path);1232 try checked_paths.append(rel_path);
1233 var buffer: [fs.MAX_PATH_BYTES]u8 = undefined;1233 var buffer: [fs.max_path_bytes]u8 = undefined;
1234 const full_path = fs.realpath(rel_path, &buffer) catch continue;1234 const full_path = fs.realpath(rel_path, &buffer) catch continue;
1235 break :full_path try arena.dupe(u8, full_path);1235 break :full_path try arena.dupe(u8, full_path);
1236 }1236 }
...@@ -1243,7 +1243,7 @@ fn parseDependentDylibs(self: *MachO) !void {...@@ -1243,7 +1243,7 @@ fn parseDependentDylibs(self: *MachO) !void {
1243 }1243 }
12441244
1245 try checked_paths.append(try arena.dupe(u8, id.name));1245 try checked_paths.append(try arena.dupe(u8, id.name));
1246 var buffer: [fs.MAX_PATH_BYTES]u8 = undefined;1246 var buffer: [fs.max_path_bytes]u8 = undefined;
1247 if (fs.realpath(id.name, &buffer)) |full_path| {1247 if (fs.realpath(id.name, &buffer)) |full_path| {
1248 break :full_path try arena.dupe(u8, full_path);1248 break :full_path try arena.dupe(u8, full_path);
1249 } else |_| {1249 } else |_| {
src/link/MachO/Dylib.zig+1-1
...@@ -831,7 +831,7 @@ pub const Id = struct {...@@ -831,7 +831,7 @@ pub const Id = struct {
831 var out: u32 = 0;831 var out: u32 = 0;
832 var values: [3][]const u8 = undefined;832 var values: [3][]const u8 = undefined;
833833
834 var split = mem.split(u8, string, ".");834 var split = mem.splitScalar(u8, string, '.');
835 var count: u4 = 0;835 var count: u4 = 0;
836 while (split.next()) |value| {836 while (split.next()) |value| {
837 if (count > 2) {837 if (count > 2) {
src/link/Plan9.zig+1-1
...@@ -365,7 +365,7 @@ fn putFn(self: *Plan9, decl_index: InternPool.DeclIndex, out: FnDeclOutput) !voi...@@ -365,7 +365,7 @@ fn putFn(self: *Plan9, decl_index: InternPool.DeclIndex, out: FnDeclOutput) !voi
365 try a.writer().writeInt(u16, 1, .big);365 try a.writer().writeInt(u16, 1, .big);
366366
367 // getting the full file path367 // getting the full file path
368 var buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;368 var buf: [std.fs.max_path_bytes]u8 = undefined;
369 const full_path = try std.fs.path.join(arena, &.{369 const full_path = try std.fs.path.join(arena, &.{
370 file.mod.root.root_dir.path orelse try std.posix.getcwd(&buf),370 file.mod.root.root_dir.path orelse try std.posix.getcwd(&buf),
371 file.mod.root.sub_path,371 file.mod.root.sub_path,
src/link/Wasm/Archive.zig+1-1
...@@ -192,7 +192,7 @@ pub fn parseObject(archive: Archive, wasm_file: *const Wasm, file_offset: u32) !...@@ -192,7 +192,7 @@ pub fn parseObject(archive: Archive, wasm_file: *const Wasm, file_offset: u32) !
192192
193 const object_name = try archive.parseName(header);193 const object_name = try archive.parseName(header);
194 const name = name: {194 const name = name: {
195 var buffer: [std.fs.MAX_PATH_BYTES]u8 = undefined;195 var buffer: [std.fs.max_path_bytes]u8 = undefined;
196 const path = try std.posix.realpath(archive.name, &buffer);196 const path = try std.posix.realpath(archive.name, &buffer);
197 break :name try std.fmt.allocPrint(gpa, "{s}({s})", .{ path, object_name });197 break :name try std.fmt.allocPrint(gpa, "{s}({s})", .{ path, object_name });
198 };198 };
test/standalone/self_exe_symlink/main.zig+1-1
...@@ -10,7 +10,7 @@ pub fn main() !void {...@@ -10,7 +10,7 @@ pub fn main() !void {
1010
11 var self_exe = try std.fs.openSelfExe(.{});11 var self_exe = try std.fs.openSelfExe(.{});
12 defer self_exe.close();12 defer self_exe.close();
13 var buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;13 var buf: [std.fs.max_path_bytes]u8 = undefined;
14 const self_exe_path = try std.os.getFdPath(self_exe.handle, &buf);14 const self_exe_path = try std.os.getFdPath(self_exe.handle, &buf);
1515
16 try std.testing.expectEqualStrings(self_exe_path, self_path);16 try std.testing.expectEqualStrings(self_exe_path, self_path);
test/standalone/windows_argv/fuzz.zig+2-2
...@@ -32,7 +32,7 @@ pub fn main() !void {...@@ -32,7 +32,7 @@ pub fn main() !void {
32 }32 }
33 break :seed try std.fmt.parseUnsigned(u64, args[3], 10);33 break :seed try std.fmt.parseUnsigned(u64, args[3], 10);
34 };34 };
35 var random = std.rand.DefaultPrng.init(seed);35 var random = std.Random.DefaultPrng.init(seed);
36 const rand = random.random();36 const rand = random.random();
3737
38 // If the seed was not given via the CLI, then output the38 // If the seed was not given via the CLI, then output the
...@@ -72,7 +72,7 @@ pub fn main() !void {...@@ -72,7 +72,7 @@ pub fn main() !void {
72 }72 }
73}73}
7474
75fn randomCommandLineW(allocator: Allocator, rand: std.rand.Random) ![:0]const u16 {75fn randomCommandLineW(allocator: Allocator, rand: std.Random) ![:0]const u16 {
76 const Choice = enum {76 const Choice = enum {
77 backslash,77 backslash,
78 quote,78 quote,
test/standalone/windows_bat_args/fuzz.zig+2-2
...@@ -27,7 +27,7 @@ pub fn main() anyerror!void {...@@ -27,7 +27,7 @@ pub fn main() anyerror!void {
27 };27 };
28 break :seed try std.fmt.parseUnsigned(u64, seed_arg, 10);28 break :seed try std.fmt.parseUnsigned(u64, seed_arg, 10);
29 };29 };
30 var random = std.rand.DefaultPrng.init(seed);30 var random = std.Random.DefaultPrng.init(seed);
31 const rand = random.random();31 const rand = random.random();
3232
33 // If the seed was not given via the CLI, then output the33 // If the seed was not given via the CLI, then output the
...@@ -109,7 +109,7 @@ fn testExecBat(allocator: std.mem.Allocator, bat: []const u8, args: []const []co...@@ -109,7 +109,7 @@ fn testExecBat(allocator: std.mem.Allocator, bat: []const u8, args: []const []co
109 }109 }
110}110}
111111
112fn randomArg(allocator: Allocator, rand: std.rand.Random) ![]const u8 {112fn randomArg(allocator: Allocator, rand: std.Random) ![]const u8 {
113 const Choice = enum {113 const Choice = enum {
114 backslash,114 backslash,
115 quote,115 quote,