Changeset

7127:27557dd7b460

moduleapi: Add API method for getting a file path
author Kim Alvefur <zash@zash.se>
date Thu, 04 Feb 2016 10:05:35 +0100
parents 7125:631c47a65519
children 7128:fccf340f4e1e
files core/moduleapi.lua
diffstat 1 files changed, 14 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/core/moduleapi.lua	Thu Feb 04 14:56:49 2016 +0000
+++ b/core/moduleapi.lua	Thu Feb 04 10:05:35 2016 +0100
@@ -301,6 +301,20 @@
 	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