Skip to content

Mode

Unix st_mode bits: permissions, the set-user-ID/set-group-ID/sticky bits, and the file type.

Example

Reading a file's mode and applying it elsewhere:

let mode = metadata("template.sh").mode
update_metadata "script.sh" mode: $mode
let rw = Mode(:OWNER_READ:, :OWNER_WRITE:)

Inherits from: Iterable[ModeBit]

Implements: std.FlagSet[ModeBit]

Class Methods

from_int value -> Mode

Constructs a mode from a raw st_mode value, preserving unknown bits.

Parameters

NameTypeDescription
value Int Raw mode bits.

Example

let mode = Mode.from_int 0o644

Fields

group @ security.unix.Permission

Group permissions.

int @ Int

The raw st_mode value, including the file type bits.

Mask with 0o7777 for the permission bits alone.

let mode = metadata("script.sh").mode
assert_eq (mode.int & 0o7777) 0o755
other @ security.unix.Permission

Permissions for everyone else.

owner @ security.unix.Permission

Owner permissions.