aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2018-08-14 12:31:32 +1000
committerHisham Muhammad <hisham@gobolinux.org>2018-08-14 13:25:51 -0300
commitbc187e06358a749cfc5d0974549cee7e1116f8bf (patch)
tree768fab6946040b41914719ec08daf3e23d34bc3d
parent70198f8b7d151714f4cbfd71f32407706d314c34 (diff)
downloadluarocks-bc187e06358a749cfc5d0974549cee7e1116f8bf.tar.gz
luarocks-bc187e06358a749cfc5d0974549cee7e1116f8bf.tar.bz2
luarocks-bc187e06358a749cfc5d0974549cee7e1116f8bf.zip
fs/unix: hoist constants out of function
-rw-r--r--src/luarocks/fs/unix.lua29
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)
169end 169end
170 170
171local 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}
181local rwx_to_octal = {}
182for octal, rwx in pairs(octal_to_rwx) do
183 rwx_to_octal[rwx] = octal
184end
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
174function unix._unix_moderate_permissions(perms) 188function 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 = ""