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;...@@ -22,16 +22,17 @@ pub const GetCwdError = posix.GetCwdError;
22/// The result is a slice of `out_buffer`, from index `0`.22/// The result is a slice of `out_buffer`, from index `0`.
23/// On Windows, the result is encoded as [WTF-8](https://wtf-8.codeberg.page/).23/// On Windows, the result is encoded as [WTF-8](https://wtf-8.codeberg.page/).
24/// On other platforms, the result is an opaque sequence of bytes with no particular encoding.24/// 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 {
26 return posix.getcwd(out_buffer);26 return posix.getcwd(out_buffer);
27}27}
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
31/// Caller must free the returned memory.32/// Caller must free the returned memory.
32/// On Windows, the result is encoded as [WTF-8](https://wtf-8.codeberg.page/).33/// On Windows, the result is encoded as [WTF-8](https://wtf-8.codeberg.page/).
33/// On other platforms, the result is an opaque sequence of bytes with no particular encoding.34/// 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 {
35 // The use of max_path_bytes here is just a heuristic: most paths will fit36 // 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.37 // in stack_buf, avoiding an extra allocation in the common case.
37 var stack_buf: [fs.max_path_bytes]u8 = undefined;38 var stack_buf: [fs.max_path_bytes]u8 = undefined;