Software /
code /
prosody
Comparison
util/paths.lua @ 11200:bf8f2da84007
Merge 0.11->trunk
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Thu, 05 Nov 2020 22:31:25 +0100 |
parent | 11183:2ac63715ef6f |
comparison
equal
deleted
inserted
replaced
11199:6c7c50a4de32 | 11200:bf8f2da84007 |
---|---|
35 return "%"..c; | 35 return "%"..c; |
36 end | 36 end |
37 end).."$"; | 37 end).."$"; |
38 end | 38 end |
39 | 39 |
40 function path_util.join(...) | 40 function path_util.join(a, b, c, ...) -- (... : string) --> string |
41 return t_concat({...}, path_sep); | 41 -- Optimization: Avoid creating table for most uses |
42 if b then | |
43 if c then | |
44 if ... then | |
45 return t_concat({a,b,c,...}, path_sep); | |
46 end | |
47 return a..path_sep..b..path_sep..c; | |
48 end | |
49 return a..path_sep..b; | |
50 end | |
51 return a; | |
52 end | |
53 | |
54 function path_util.complement_lua_path(installer_plugin_path) | |
55 -- Checking for duplicates | |
56 -- The commands using luarocks need the path to the directory that has the /share and /lib folders. | |
57 local lua_version = _VERSION:match(" (.+)$"); | |
58 local lua_path_sep = package.config:sub(3,3); | |
59 local dir_sep = package.config:sub(1,1); | |
60 local sub_path = dir_sep.."lua"..dir_sep..lua_version..dir_sep; | |
61 if not string.find(package.path, installer_plugin_path, 1, true) then | |
62 package.path = package.path..lua_path_sep..installer_plugin_path..dir_sep.."share"..sub_path.."?.lua"; | |
63 package.path = package.path..lua_path_sep..installer_plugin_path..dir_sep.."share"..sub_path.."?"..dir_sep.."init.lua"; | |
64 end | |
65 if not string.find(package.path, installer_plugin_path, 1, true) then | |
66 package.cpath = package.cpath..lua_path_sep..installer_plugin_path..dir_sep.."lib"..sub_path.."?.so"; | |
67 end | |
42 end | 68 end |
43 | 69 |
44 return path_util; | 70 return path_util; |