Zig 0.17.0-dev (Split by item) This is an example of documentation generated by
ZigDoc , an alternative to Zig's built-in
Auto Doc feature. See also
examples in other modes/formats . The project being documented here (as the example) is the Zig standard library.
std › Io › Threaded › processSetCurrentPath Private Function processSetCurrentPath Doc Source Private Function std.Io.Threaded.processSetCurrentPath
fn processSetCurrentPath (userdata : ?*anyopaque , path : []const u8 ) process .SetCurrentPathError !void Params userdata : ?*anyopaque path : []const u8 File Io/Threaded.zig: 14216
14216
14217
14218
14219
14220
14221
14222
14223
14224
14225
14226
14227
14228
14229
14230
14231
14232
14233
14234
14235
14236
14237
14238
14239
14240
14241
14242
14243
14244
14245
14246
14247
14248
14249
14250
14251 fn processSetCurrentPath (userdata : ?*anyopaque , path : []const u8 ) process .SetCurrentPathError !void {
const t : *Threaded = @ptrCast (@alignCast (userdata ));
_ = t ;
if (native_os == .wasi ) return error .OperationUnsupported ;
if (is_windows ) {
var path_w_buf : [windows .PATH_MAX_WIDE ]u16 = undefined ;
const len = std .unicode .calcWtf16LeLen (path ) catch return error .InvalidWtf8 ;
if (len > path_w_buf .len ) return error .NameTooLong ;
const path_w_len = std .unicode .wtf8ToWtf16Le (&path_w_buf , path ) catch |err | switch (err ) {
error .InvalidWtf8 => unreachable , // already validated
};
const path_w = path_w_buf [0 ..path_w_len ];
const syscall : Syscall = try .start ();
while (true ) switch (windows .ntdll .RtlSetCurrentDirectory_U (&.init (path_w ))) {
.SUCCESS => return syscall .finish (),
.OBJECT_NAME_INVALID => return syscall .fail (error .BadPathName ),
.OBJECT_NAME_NOT_FOUND => return syscall .fail (error .FileNotFound ),
.OBJECT_PATH_NOT_FOUND => return syscall .fail (error .FileNotFound ),
.NO_MEDIA_IN_DEVICE => return syscall .fail (error .NoDevice ),
.INVALID_PARAMETER => |err | return syscall .ntstatusBug (err ),
.ACCESS_DENIED => return syscall .fail (error .AccessDenied ),
.OBJECT_PATH_SYNTAX_BAD => |err | return syscall .ntstatusBug (err ),
.NOT_A_DIRECTORY => return syscall .fail (error .NotDir ),
.CANCELLED => {
try syscall .checkCancel ();
continue ;
},
else => |status | return syscall .unexpectedNtstatus (status ),
};
}
return chdir (path );
}