Skip to content

Commit 26afcdb

Browse files
committed
std.process: Actually use explicit GetCwdError/GetCwdAllocError sets
Also fix GetCwdAllocError to include only the set of possible errors.
1 parent fb1bd78 commit 26afcdb

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lib/std/process.zig

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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.
25-
pub fn getCwd(out_buffer: []u8) ![]u8 {
25+
pub fn getCwd(out_buffer: []u8) GetCwdError![]u8 {
2626
return posix.getcwd(out_buffer);
2727
}
2828

29-
pub const GetCwdAllocError = Allocator.Error || posix.GetCwdError;
29+
// Same as GetCwdError, minus error.NameTooLong + Allocator.Error
30+
pub 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.
34-
pub fn getCwdAlloc(allocator: Allocator) ![]u8 {
35+
pub 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;

0 commit comments

Comments
 (0)