diff options
| author | daurnimator <quae@daurnimator.com> | 2018-08-14 12:31:32 +1000 |
|---|---|---|
| committer | Hisham Muhammad <hisham@gobolinux.org> | 2018-08-14 13:25:51 -0300 |
| commit | bc187e06358a749cfc5d0974549cee7e1116f8bf (patch) | |
| tree | 768fab6946040b41914719ec08daf3e23d34bc3d | |
| parent | 70198f8b7d151714f4cbfd71f32407706d314c34 (diff) | |
| download | luarocks-bc187e06358a749cfc5d0974549cee7e1116f8bf.tar.gz luarocks-bc187e06358a749cfc5d0974549cee7e1116f8bf.tar.bz2 luarocks-bc187e06358a749cfc5d0974549cee7e1116f8bf.zip | |
fs/unix: hoist constants out of function
| -rw-r--r-- | src/luarocks/fs/unix.lua | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/src/luarocks/fs/unix.lua b/src/luarocks/fs/unix.lua index f8e272a7..0126dad5 100644 --- a/src/luarocks/fs/unix.lua +++ b/src/luarocks/fs/unix.lua | |||
| @@ -168,25 +168,24 @@ function unix.export_cmd(var, val) | |||
| 168 | return ("export %s='%s'"):format(var, val) | 168 | return ("export %s='%s'"):format(var, val) |
| 169 | end | 169 | end |
| 170 | 170 | ||
| 171 | local octal_to_rwx = { | ||
| 172 | ["0"] = "---", | ||
| 173 | ["1"] = "--x", | ||
| 174 | ["2"] = "-w-", | ||
| 175 | ["3"] = "-wx", | ||
| 176 | ["4"] = "r--", | ||
| 177 | ["5"] = "r-x", | ||
| 178 | ["6"] = "rw-", | ||
| 179 | ["7"] = "rwx", | ||
| 180 | } | ||
| 181 | local rwx_to_octal = {} | ||
| 182 | for octal, rwx in pairs(octal_to_rwx) do | ||
| 183 | rwx_to_octal[rwx] = octal | ||
| 184 | end | ||
| 171 | --- Moderate the given permissions based on the local umask | 185 | --- Moderate the given permissions based on the local umask |
| 172 | -- @param perms string: permissions to moderate | 186 | -- @param perms string: permissions to moderate |
| 173 | -- @return string: the moderated permissions | 187 | -- @return string: the moderated permissions |
| 174 | function unix._unix_moderate_permissions(perms) | 188 | function unix._unix_moderate_permissions(perms) |
| 175 | local octal_to_rwx = { | ||
| 176 | ["0"] = "---", | ||
| 177 | ["1"] = "--x", | ||
| 178 | ["2"] = "-w-", | ||
| 179 | ["3"] = "-wx", | ||
| 180 | ["4"] = "r--", | ||
| 181 | ["5"] = "r-x", | ||
| 182 | ["6"] = "rw-", | ||
| 183 | ["7"] = "rwx", | ||
| 184 | } | ||
| 185 | local rwx_to_octal = {} | ||
| 186 | for octal, rwx in pairs(octal_to_rwx) do | ||
| 187 | rwx_to_octal[rwx] = octal | ||
| 188 | end | ||
| 189 | |||
| 190 | local umask = fs._unix_umask() | 189 | local umask = fs._unix_umask() |
| 191 | 190 | ||
| 192 | local moderated_perms = "" | 191 | local moderated_perms = "" |
