From 66a03adf5dba1e9ddb40ec400e05c60373ec12d9 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Thu, 4 Feb 2016 10:05:35 +0100 Subject: moduleapi: Add API method for getting a file path --- core/moduleapi.lua | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/core/moduleapi.lua b/core/moduleapi.lua index c439ba6f..573f3153 100644 --- a/core/moduleapi.lua +++ b/core/moduleapi.lua @@ -301,6 +301,20 @@ function api:get_option_inherited_set(name, ...) return value; end +function api:get_option_path(name, default, parent) + if parent == nil then + parent = parent or self:get_directory(); + elseif prosody.paths[parent] then + parent = prosody.paths[parent]; + end + local value = self:get_option_string(name, default); + if value == nil then + return nil; + end + return resolve_relative_path(parent, value); +end + + function api:context(host) return setmetatable({host=host or "*"}, {__index=self,__newindex=self}); end -- cgit v1.2.3