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. Public Constant
pubconstPermissions = std.Options.FilePermissionsorelseif (is_windows) enum(std.os.windows.DWORD) {
default_file = 0,
_,
pubconstdefault_dir: @This() = .default_file;
pubconstexecutable_file: @This() = .default_file;
pubconsthas_executable_bit = false;
constwindows = std.os.windows;
pubfntoAttributes(self: @This()) windows.FILE.ATTRIBUTE {
return@bitCast(@backingInt(self));
}
pubfnreadOnly(self: @This()) bool {
constattributes = toAttributes(self);
returnattributes & windows.FILE_ATTRIBUTE_READONLY != 0;
}
pubfnsetReadOnly(self: @This(), read_only: bool) @This() {
constattributes = toAttributes(self);
return@fromBackingInt(@intCast(if (read_only)
attributes | windows.FILE_ATTRIBUTE_READONLYelseattributes & ~@as(windows.DWORD, windows.FILE_ATTRIBUTE_READONLY)));
}
} elseif (std.posix.mode_t != u0) enum(std.posix.mode_t) {
/// This is the default mode given to POSIX operating systems for creating/// files. `0o666` is "-rw-rw-rw-" which is counter-intuitive at first,/// since most people would expect "-rw-r--r--", for example, when using/// the `touch` command, which would correspond to `0o644`. However, POSIX/// libc implementations use `0o666` inside `fopen` and then rely on the/// process-scoped "umask" setting to adjust this number for file creation.default_file = 0o666,
/// This is the default mode given to POSIX operating systems for creating/// directories. `0o777` is "-rwxrwxrwx" which is counter-intuitive at first,/// since most people would expect "-rwxr-xr-x", for example, when using/// the `touch` command, which would correspond to `0o755`.default_dir = 0o777,
_,
pubconsthas_executable_bit = native_os != .wasi;
pubconstexecutable_file: @This() = .default_dir;
pubfntoMode(self: @This()) std.posix.mode_t {
return@backingInt(self);
}
pubfnfromMode(mode: std.posix.mode_t) @This() {
return@fromBackingInt(@intCast(mode));
}
/// Returns `true` if and only if no class has write permissions.pubfnreadOnly(self: @This()) bool {
constmode = toMode(self);
returnmode & 0o222 == 0;
}
/// Enables write permission for all classes.pubfnsetReadOnly(self: @This(), read_only: bool) @This() {
constmode = toMode(self);
consto222 = @as(std.posix.mode_t, 0o222);
return@fromBackingInt(@intCast(if (read_only) mode & ~o222elsemode | o222));
}
} elseenum(u0) {
default_file = 0,
pubconstdefault_dir: @This() = .default_file;
pubconstexecutable_file: @This() = .default_file;
pubconsthas_executable_bit = false;
}
Cross-platform representation of permissions on a file.
On POSIX systems this corresponds to "mode" and on Windows this corresponds to "attributes".