struct Permissions [src]
Cross-platform representation of permissions on a file.
The readonly and setReadonly are the only methods available across all platforms.
Platform-specific functionality is available through the inner field.
Fields
inner: switch (builtin.os.tag) {
.windows => PermissionsWindows,
else => PermissionsUnix,
}You may use the inner field to use platform-specific functionality
Members
- readOnly (Function)
- setReadOnly (Function)
Source
pub const Permissions = struct {
/// You may use the `inner` field to use platform-specific functionality
inner: switch (builtin.os.tag) {
.windows => PermissionsWindows,
else => PermissionsUnix,
},
const Self = @This();
/// Returns `true` if permissions represent an unwritable file.
/// On Unix, `true` is returned only if no class has write permissions.
pub fn readOnly(self: Self) bool {
return self.inner.readOnly();
}
/// Sets whether write permissions are provided.
/// On Unix, this affects *all* classes. If this is undesired, use `unixSet`.
/// This method *DOES NOT* set permissions on the filesystem: use `File.setPermissions(permissions)`
pub fn setReadOnly(self: *Self, read_only: bool) void {
self.inner.setReadOnly(read_only);
}
}