Function makeDir [src]

Creates a single directory with a relative or absolute path. To create multiple directories to make an entire path, see makePath. To operate on only absolute paths, see makeDirAbsolute. On Windows, sub_path should be encoded as WTF-8. On WASI, sub_path should be encoded as valid UTF-8. On other platforms, sub_path is an opaque sequence of bytes with no particular encoding.

Prototype

pub fn makeDir(self: Dir, sub_path: []const u8) MakeError!void

Parameters

self: Dirsub_path: []const u8

Possible Errors

AccessDenied MakeDirError

In WASI, this error may occur when the file descriptor does not hold the required rights to create a new directory relative to it.

BadPathName MakeDirError
DiskQuota MakeDirError
FileNotFound MakeDirError
InvalidUtf8 MakeDirError

WASI-only; file paths must be valid UTF-8.

InvalidWtf8 MakeDirError

Windows-only; file paths provided by the user must be valid WTF-8. https://simonsapin.github.io/wtf-8/

LinkQuotaExceeded MakeDirError
NameTooLong MakeDirError
NetworkNotFound MakeDirError

On Windows, \\server or \\server\share was not found.

NoDevice MakeDirError
NoSpaceLeft MakeDirError
NotDir MakeDirError
PathAlreadyExists MakeDirError
PermissionDenied MakeDirError
ReadOnlyFileSystem MakeDirError
SymLinkLoop MakeDirError
SystemResources MakeDirError
Unexpected UnexpectedError

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 makeDir(self: Dir, sub_path: []const u8) MakeError!void { try posix.mkdirat(self.fd, sub_path, default_mode); }