authorgravatar for mason1920@protonmail.commason1920 <mason1920@protonmail.com> 2021-06-20 00:21:59-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-06-21 16:18:59-07:00
log939408289cd05ba2f3b90eb626a388b6a5c747c4
tree4dadcf4c4a9b70f9b706d3ed3aaef9d0f1275883
parentd0575310dce6d8592576951fb2a21640e00141f9

Bring your own MAX_PATH_BYTES

Previous to #7082, users could overwrite PATH_MAX in the root file to support std.os.toPosixPath, permitting the "bring your own operating system" layer to implement the POSIX API for opening files. Unfortunately that is no longer the case. This commit intends to fix what is arguably a regression from 0.7 in a way that doesn't break any code targeting 0.8.0, making it suitable to be included in a 0.8 patch release. However in a future release that permits breaking changes, I am of the opinion that it would be beneficial to overwrite the value, even for "supported" operating systems. Same for all the other POSIX/BYOOS functions and values. However this is beyond the scope of this commit. Further discussion of this will be made into an issue in due time.

1 files changed, 5 insertions(+), 1 deletions(-)

lib/std/fs.zig+5-1
......@@ -3,6 +3,7 @@
33// This file is part of [zig](https://ziglang.org/), which is MIT licensed.
44// The MIT license requires this copyright notice to be included in all copies
55// and substantial portions of the software.
6const root = @import("root");
67const builtin = std.builtin;
78const std = @import("std.zig");
89const os = std.os;
......@@ -47,7 +48,10 @@ pub const MAX_PATH_BYTES = switch (builtin.os.tag) {
4748 .windows => os.windows.PATH_MAX_WIDE * 3 + 1,
4849 // TODO work out what a reasonable value we should use here
4950 .wasi => 4096,
50 else => @compileError("Unsupported OS"),
51 else => if (@hasDecl(root, "os") and @hasDecl(root.os, "PATH_MAX"))
52 root.os.PATH_MAX
53 else
54 @compileError("PATH_MAX not implemented for " ++ @tagName(builtin.os.tag)),
5155};
5256
5357pub const base64_alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".*;