Function rmdirZ [src]
Same as rmdir except the parameter is null-terminated.
On Windows, dir_path should be encoded as WTF-8.
On WASI, dir_path should be encoded as valid UTF-8.
On other platforms, dir_path is an opaque sequence of bytes with no particular encoding.
Prototype
pub fn rmdirZ(dir_path: [*:0]const u8) DeleteDirError!void
Parameters
dir_path: [*:0]const u8
Possible Errors
WASI-only; file paths must be valid UTF-8.
Windows-only; file paths provided by the user must be valid WTF-8. https://simonsapin.github.io/wtf-8/
On Windows, \\server
or \\server\share
was not found.
The Operating System returned an undocumented error code.
This error is in theory not possible, but it would be better to handle this error than to invoke undefined behavior.
When this error code is observed, it usually means the Zig Standard Library needs a small patch to add the error code to the error set for the respective function.
Source
pub fn rmdirZ(dir_path: [*:0]const u8) DeleteDirError!void {
if (native_os == .windows) {
const dir_path_w = try windows.cStrToPrefixedFileW(null, dir_path);
return rmdirW(dir_path_w.span());
} else if (native_os == .wasi and !builtin.link_libc) {
return rmdir(mem.sliceTo(dir_path, 0));
}
switch (errno(system.rmdir(dir_path))) {
.SUCCESS => return,
.ACCES => return error.AccessDenied,
.PERM => return error.PermissionDenied,
.BUSY => return error.FileBusy,
.FAULT => unreachable,
.INVAL => return error.BadPathName,
.LOOP => return error.SymLinkLoop,
.NAMETOOLONG => return error.NameTooLong,
.NOENT => return error.FileNotFound,
.NOMEM => return error.SystemResources,
.NOTDIR => return error.NotDir,
.EXIST => return error.DirNotEmpty,
.NOTEMPTY => return error.DirNotEmpty,
.ROFS => return error.ReadOnlyFileSystem,
.ILSEQ => |err| if (native_os == .wasi)
return error.InvalidUtf8
else
return unexpectedErrno(err),
else => |err| return unexpectedErrno(err),
}
}