Module permissions

Provides utilities for working with file permissions.

Functions

strtobmp (permstr) Convert a string representation to a binary one.
bmptostr (bitmap) Convert a bitmap representation to a string.
has_permission (mode, perm) Check if a permission is set.


Functions

strtobmp (permstr)
Convert a string representation to a binary one. Takes a string in a form similar to that output by ls, and returns a number with the appropriate bits set. The string must be exactly nine characters long and in the format rwxrwxrwx, where any r, w, or x may be replaced by a -. For example, rwxrw-r--, r-xr-xr-x, and rw--wx--w- are all valid, but rwrwrw is not.

Parameters:

  • permstr string The string to process

Returns:

    number A numerical representation of the input string
bmptostr (bitmap)
Convert a bitmap representation to a string. The bitmap must be in the same format as a POSIX file mode - the same as that returned by strtobmp.

Parameters:

  • bitmap number The permissions to process

Returns:

    string A string representation, in the same form as passed to strtobmp.
has_permission (mode, perm)
Check if a permission is set. Checks if the given permission string, when ANDed with the given mode, is exactly returned. Relatively inflexible.

Parameters:

  • mode number The file mode to check against
  • perm string The permissions to check

Returns:

    boolean Whether the given permission is set
generated by LDoc 1.4.6 Last updated 2023-03-04 11:42:14