Permissions structv0.1.0
pub struct Permissions {
pub mode: uint32;
// private fields
}
mode is the Unix permission bits, the low nine of which are the owner/group/other triple. readOnly is
Windows' one portable attribute. Both are always filled: on Windows the mode is synthesized from the
attribute (0o444 when read-only, 0o666 otherwise) so a program that reasons in Unix terms is not blocked,
and on Unix readOnly reports whether the owner-write bit is clear. Capabilities says which one is real.
Fields
| Name | Type | Description |
|---|---|---|
mode | uint32 | The Unix permission bits. |
Associated functions
FromMode
pub func FromMode(mode: uint32) -> Permissions
Permissions from Unix mode bits, with readOnly derived from the owner-write bit.
| Name | Type | Description |
|---|---|---|
mode | uint32 | the permission bits |
Returns: permissions carrying those bits
FromReadOnly
pub func FromReadOnly(readOnly: bool) -> Permissions
Permissions from the read-only flag alone, with the mode synthesized from it.
| Name | Type | Description |
|---|---|---|
readOnly | bool | whether the file may only be read |
Returns: permissions that are writable or not, which is all Windows records
Methods
IsWritable
pub func IsWritable(self: &Permissions) -> bool
Whether the owner may write.
Returns: whether the owner may write the file
Related
SetPermissions
pub func SetPermissions(
allocator: Allocator,
path: Path,
permissions: Permissions
) -> ! IoError
Sets who may do what to the file path names.
On the Unix systems the mode bits are written as given. On Windows only the read-only attribute exists, so
that alone is written and the rest of permissions is ignored — ask CapabilitiesOfSystem first if the
difference matters. A symbolic link is always followed: its own bits mean nothing on any supported system.
Parameters
| Name | Type | Description |
|---|---|---|
allocator | Allocator | where the storage comes from |
path | Path | the path to act on |
permissions | Permissions | the permissions to apply |
Returns: success when the permissions were applied