Permissions structv0.1.0

Source
Who may do what to a file, in both spellings the supported systems use.
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

NameTypeDescription
modeuint32The 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.

NameTypeDescription
modeuint32the permission bits

Returns: permissions carrying those bits

Source

FromReadOnly

pub func FromReadOnly(readOnly: bool) -> Permissions

Permissions from the read-only flag alone, with the mode synthesized from it.

NameTypeDescription
readOnlyboolwhether the file may only be read

Returns: permissions that are writable or not, which is all Windows records

Source

Methods

IsWritable

pub func IsWritable(self: &Permissions) -> bool

Whether the owner may write.

Returns: whether the owner may write the file

Source

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.

Source

Parameters

NameTypeDescription
allocatorAllocatorwhere the storage comes from
pathPaththe path to act on
permissionsPermissionsthe permissions to apply

Returns: success when the permissions were applied