Module Filesystem_types.File_permissions

module type S = sig ... end
include S
type t

Represents unix file permissions.

include Ppx_compare_lib.Comparable.S with type t := t
val compare : t -> t -> int
include Ppx_compare_lib.Equal.S with type t := t
val equal : t -> t -> bool
include Ppx_compare_lib.Equal.S__local with type t := t
include Ppx_hash_lib.Hashable.S_any with type t := t
val hash_fold_t : t Ppx_hash_lib.hash_fold
include Ppx_quickcheck_runtime.Quickcheckable.S with type t := t
val quickcheck_generator : t Base_quickcheck.Generator.t
val quickcheck_observer : t Base_quickcheck.Observer.t
val quickcheck_shrinker : t Base_quickcheck.Shrinker.t
val sexp_of_t : t -> Sexplib0.Sexp.t @@ portable

Constants

val empty : t @@ portable

No permissions.

Individual file permission bits.

val u_r : t @@ portable
val u_w : t @@ portable
val u_x : t @@ portable
val g_r : t @@ portable
val g_w : t @@ portable
val g_x : t @@ portable
val o_r : t @@ portable
val o_w : t @@ portable
val o_x : t @@ portable

All file permission bits, i.e. 0o0777.

val ugo_rwx : t @@ portable

Combining permissions with rw (read/write), rx (executables), and rwx (e.g. directories or symlinks).

val u_rw : t @@ portable
val g_rw : t @@ portable
val o_rw : t @@ portable
val u_rx : t @@ portable
val g_rx : t @@ portable
val o_rx : t @@ portable
val u_rwx : t @@ portable
val g_rwx : t @@ portable
val o_rwx : t @@ portable

Combining permissions with ug (user and group) and ugo (everyone).

val ug_r : t @@ portable
val ug_w : t @@ portable
val ug_x : t @@ portable
val ug_rw : t @@ portable
val ug_rx : t @@ portable
val ug_rwx : t @@ portable
val ugo_r : t @@ portable
val ugo_w : t @@ portable
val ugo_x : t @@ portable
val ugo_rw : t @@ portable
val ugo_rx : t @@ portable

Commonly used combinations.

val t_0644 : t @@ portable

u_rw lor ugo_r, i.e. of_int_exn 0o0644

val t_0664 : t @@ portable

ug_rw lor ugo_r, i.e. of_int_exn 0o0664

val t_0755 : t @@ portable

u_rwx lor ugo_rx, i.e. of_int_exn 0o0755

val t_0775 : t @@ portable

ug_rwx lor ugo_rx, i.e. of_int_exn 0o0775

Special mode bits, used for properties other than actual file permissions.

val setuid : t @@ portable
val setgid : t @@ portable
val sticky : t @@ portable
val special_mode_bits : t @@ portable

Equivalent to setuid lor setgid lor sticky, i.e. 0o7000.

val all_including_special_mode_bits : t @@ portable

Equivalent to ugo_rwx lor special_mode_bits, i.e. 0o7777.

Predicates

val is_empty : t -> bool @@ portable

Test if the input is empty.

val do_intersect : t -> t -> bool @@ portable

Test if two permissions contain at least one set bit in common.

val is_subset : t -> of_:t -> bool @@ portable

Test if t contains only permission bits also set in of_.

Constructors

val intersection : t -> t -> t @@ portable

Produce only the permissions contained in both inputs.

val union : t -> t -> t @@ portable

Produce all permissions contained in either or both inputs.

val symmetric_diff : t -> t -> t @@ portable

Produce permissions contained in either input but not both.

Operators

module Operators : sig ... end
val (land) : t -> t -> t @@ portable

Alias for intersection.

val (lor) : t -> t -> t @@ portable

Alias for union.

val (lxor) : t -> t -> t @@ portable

Alias for symmetric_diff.

Integer conversion

Permissions are represented as unsigned 12-bit integers. The definitions of individual permission bits above proceed from most significant bit to least significant bit in the integer representation.

val of_int_exn : int -> t @@ portable
val to_int : t -> int @@ portable