|
| 1 | +## Module Node.FS.Perms |
| 2 | + |
| 3 | +#### `Perm` |
| 4 | + |
| 5 | +``` purescript |
| 6 | +newtype Perm |
| 7 | +``` |
| 8 | + |
| 9 | +A `Perm` value specifies what is allowed to be done with a particular |
| 10 | +file by a particular class of user — that is, whether it is |
| 11 | +readable, writable, and/or executable. It has a `Semiring` instance, which |
| 12 | +allows you to combine permissions: |
| 13 | + |
| 14 | +- `(+)` adds `Perm` values together. For example, `read + write` means |
| 15 | + "readable and writable". |
| 16 | +- `(*)` masks permissions. It can be thought of as selecting only the |
| 17 | + permissions that two `Perm` values have in common. For example: `(read |
| 18 | + + write) * (write + execute) == write`. |
| 19 | + |
| 20 | + |
| 21 | + |
| 22 | +##### Instances |
| 23 | +``` purescript |
| 24 | +instance eqPerm :: Eq Perm |
| 25 | +instance ordPerm :: Ord Perm |
| 26 | +instance showPerm :: Show Perm |
| 27 | +instance semiringPerm :: Semiring Perm |
| 28 | +``` |
| 29 | + |
| 30 | +#### `none` |
| 31 | + |
| 32 | +``` purescript |
| 33 | +none :: Perm |
| 34 | +``` |
| 35 | + |
| 36 | +No permissions. This is the identity of the `Semiring` operation `(+)` |
| 37 | +for `Perm`; that is, it is the same as `zero`. |
| 38 | + |
| 39 | +#### `read` |
| 40 | + |
| 41 | +``` purescript |
| 42 | +read :: Perm |
| 43 | +``` |
| 44 | + |
| 45 | +The "readable" permission. |
| 46 | + |
| 47 | +#### `write` |
| 48 | + |
| 49 | +``` purescript |
| 50 | +write :: Perm |
| 51 | +``` |
| 52 | + |
| 53 | +The "writable" permission. |
| 54 | + |
| 55 | +#### `execute` |
| 56 | + |
| 57 | +``` purescript |
| 58 | +execute :: Perm |
| 59 | +``` |
| 60 | + |
| 61 | +The "executable" permission. |
| 62 | + |
| 63 | +#### `all` |
| 64 | + |
| 65 | +``` purescript |
| 66 | +all :: Perm |
| 67 | +``` |
| 68 | + |
| 69 | +All permissions: readable, writable, and executable. This is the identity |
| 70 | +of the `Semiring` operation `(*)` for `Perm`; that is, it is the same as |
| 71 | +`one`. |
| 72 | + |
| 73 | +#### `Perms` |
| 74 | + |
| 75 | +``` purescript |
| 76 | +newtype Perms |
| 77 | +``` |
| 78 | + |
| 79 | +A `Perms` value includes all the permissions information about a |
| 80 | +particular file or directory, by storing a `Perm` value for each of the |
| 81 | +file owner, the group, and any other users. |
| 82 | + |
| 83 | +##### Instances |
| 84 | +``` purescript |
| 85 | +instance eqPerms :: Eq Perms |
| 86 | +instance ordPerms :: Ord Perms |
| 87 | +instance showPerms :: Show Perms |
| 88 | +``` |
| 89 | + |
| 90 | +#### `permsFromString` |
| 91 | + |
| 92 | +``` purescript |
| 93 | +permsFromString :: String -> Maybe Perms |
| 94 | +``` |
| 95 | + |
| 96 | +Attempt to parse a `Perms` value from a `String` containing an octal |
| 97 | +integer. For example, |
| 98 | +`permsFromString "0644" == Just (mkPerms (read + write) read read)`. |
| 99 | + |
| 100 | +#### `mkPerms` |
| 101 | + |
| 102 | +``` purescript |
| 103 | +mkPerms :: Perm -> Perm -> Perm -> Perms |
| 104 | +``` |
| 105 | + |
| 106 | +Create a `Perms` value. The arguments represent the owner's, group's, and |
| 107 | +other users' permission sets, respectively. |
| 108 | + |
| 109 | +#### `permsToString` |
| 110 | + |
| 111 | +``` purescript |
| 112 | +permsToString :: Perms -> String |
| 113 | +``` |
| 114 | + |
| 115 | +Convert a `Perms` value to an octal string, in a format similar to that |
| 116 | +accepted by `chmod`. For example: |
| 117 | +`permsToString (mkPerms (read + write) read read) == "0644"` |
| 118 | + |
| 119 | +#### `permsToInt` |
| 120 | + |
| 121 | +``` purescript |
| 122 | +permsToInt :: Perms -> Int |
| 123 | +``` |
| 124 | + |
| 125 | +Convert a `Perms` value to an `Int`, via `permsToString`. |
| 126 | + |
| 127 | + |
0 commit comments