From e6f74b78ef48bc1d23ccd98d042534f0bbe3eb80 Mon Sep 17 00:00:00 2001 From: Veikka Tuominen Date: Sun, 17 Mar 2024 09:06:54 +0200 Subject: [PATCH] std: define error set of `toPosixPath` --- lib/std/dynamic_library.zig | 2 +- lib/std/os.zig | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/std/dynamic_library.zig b/lib/std/dynamic_library.zig index 5a17f38429..7a31c39f44 100644 --- a/lib/std/dynamic_library.zig +++ b/lib/std/dynamic_library.zig @@ -414,7 +414,7 @@ pub const WindowsDynLib = struct { }; pub const DlDynLib = struct { - pub const Error = error{FileNotFound}; + pub const Error = error{ FileNotFound, NameTooLong }; handle: *anyopaque, diff --git a/lib/std/os.zig b/lib/std/os.zig index 417e571145..2138f5cd20 100644 --- a/lib/std/os.zig +++ b/lib/std/os.zig @@ -5979,7 +5979,7 @@ pub fn sched_getaffinity(pid: pid_t) SchedGetAffinityError!cpu_set_t { /// Used to convert a slice to a null terminated slice on the stack. /// TODO https://github.com/ziglang/zig/issues/287 -pub fn toPosixPath(file_path: []const u8) ![MAX_PATH_BYTES - 1:0]u8 { +pub fn toPosixPath(file_path: []const u8) error{NameTooLong}![MAX_PATH_BYTES - 1:0]u8 { if (std.debug.runtime_safety) assert(std.mem.indexOfScalar(u8, file_path, 0) == null); var path_with_null: [MAX_PATH_BYTES - 1:0]u8 = undefined; // >= rather than > to make room for the null byte