authorgravatar for squeek502@hotmail.comRyan Liptak <squeek502@hotmail.com> 2025-11-19 04:09:54-08:00
committergravatar for squeek502@hotmail.comRyan Liptak <squeek502@hotmail.com> 2025-11-19 04:10:11-08:00
log26afcdb7fe95b35a3246980d249bcf0dc17dbf8b
tree7133c867498642dd9e87bf3de6185c5f8c3a371c
parentfb1bd78908ed70b00c1bf5d7d37ad216925f6db2

std.process: Actually use explicit GetCwdError/GetCwdAllocError sets

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

1 files changed, 4 insertions(+), 3 deletions(-)

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