diff options
Diffstat (limited to '')
-rw-r--r-- | src/luarocks/path.lua | 19 |
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 |
288 | end | 288 | end |
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. | ||
295 | function 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 | ||
307 | end | ||
308 | |||
290 | return path | 309 | return path |