zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 26afcdb7fe95b35a3246980d249bcf0dc17dbf8b (tree)
parent fb1bd78908ed70b00c1bf5d7d37ad216925f6db2
Author: Ryan Liptak <squeek502@hotmail.com>
Date:   Wed, 19 Nov 2025 04:09:54 -0800

std.process: Actually use explicit GetCwdError/GetCwdAllocError sets

Also fix GetCwdAllocError to include only the set of possible errors.

Diffstat:
Mlib/std/process.zig | 7++++---
1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/lib/std/process.zig b/lib/std/process.zig @@ -22,16 +22,17 @@ pub const GetCwdError = posix.GetCwdError; /// The result is a slice of `out_buffer`, from index `0`. /// On Windows, the result is encoded as [WTF-8](https://wtf-8.codeberg.page/). /// On other platforms, the result is an opaque sequence of bytes with no particular encoding. -pub fn getCwd(out_buffer: []u8) ![]u8 { +pub fn getCwd(out_buffer: []u8) GetCwdError![]u8 { return posix.getcwd(out_buffer); } -pub const GetCwdAllocError = Allocator.Error || posix.GetCwdError; +// Same as GetCwdError, minus error.NameTooLong + Allocator.Error +pub const GetCwdAllocError = Allocator.Error || error{CurrentWorkingDirectoryUnlinked} || posix.UnexpectedError; /// Caller must free the returned memory. /// On Windows, the result is encoded as [WTF-8](https://wtf-8.codeberg.page/). /// On other platforms, the result is an opaque sequence of bytes with no particular encoding. -pub fn getCwdAlloc(allocator: Allocator) ![]u8 { +pub fn getCwdAlloc(allocator: Allocator) GetCwdAllocError![]u8 { // The use of max_path_bytes here is just a heuristic: most paths will fit // in stack_buf, avoiding an extra allocation in the common case. var stack_buf: [fs.max_path_bytes]u8 = undefined;