aboutsummaryrefslogtreecommitdiff
path: root/src/luarocks/path.lua
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/luarocks/path.lua19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/luarocks/path.lua b/src/luarocks/path.lua
index f6b12727..4babcb30 100644
--- a/src/luarocks/path.lua
+++ b/src/luarocks/path.lua
@@ -287,4 +287,23 @@ function path.map_trees(deps_mode, fn, ...)
287 return result 287 return result
288end 288end
289 289
290--- Get the namespace of a locally-installed rock, if any.
291-- @param name string: The rock name, without a namespace.
292-- @param version string: The rock version.
293-- @param tree string: The local tree to use.
294-- @return string?: The namespace if it exists, or nil.
295function path.read_namespace(name, version, tree)
296 assert(type(name) == "string" and not name:match("/"))
297 assert(type(version) == "string")
298 assert(type(tree) == "string")
299
300 local namespace
301 local fd = io.open(path.rock_namespace_file(name, version, tree), "r")
302 if fd then
303 namespace = fd:read("*a")
304 fd:close()
305 end
306 return namespace
307end
308
290return path 309return path