aboutsummaryrefslogtreecommitdiffstats
path: root/prosody
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2010-07-13 13:55:18 +0100
committerMatthew Wild <mwild1@gmail.com>2010-07-13 13:55:18 +0100
commit08359fc7a678708062c485ff29150437a3bdefa4 (patch)
treec29c35a23ce9ef0f97b84dbdf3fd15e4b62286aa /prosody
parent5b93b0675f9df50181de081cb082dcea35d9b643 (diff)
downloadprosody-08359fc7a678708062c485ff29150437a3bdefa4.tar.gz
prosody-08359fc7a678708062c485ff29150437a3bdefa4.zip
prosody: Add prosody.resolve_relative_path() helper to change relative paths to be relative to the config file
Diffstat (limited to 'prosody')
-rwxr-xr-xprosody17
1 files changed, 17 insertions, 0 deletions
diff --git a/prosody b/prosody
index fd6a051c..6ec9131e 100755
--- a/prosody
+++ b/prosody
@@ -163,6 +163,23 @@ function init_global_state()
prosody.paths = { source = CFG_SOURCEDIR, config = CFG_CONFIGDIR,
plugins = CFG_PLUGINDIR, data = CFG_DATADIR };
+ local path_sep = package.config:sub(1,1);
+ local rel_path_start = ".."..path_sep;
+ function prosody.resolve_relative_path(path)
+ if path then
+ local is_relative;
+ if path_sep == "/" and path:sub(1,1) ~= "/" then
+ is_relative = true;
+ elseif path_sep == "\\" and (path:sub(1,1) ~= "/" and path:sub(2,3) ~= ":\\") then
+ is_relative = true;
+ end
+ if is_relative then
+ return CFG_CONFIGDIR..path_sep..path;
+ end
+ end
+ return path;
+ end
+
prosody.arg = _G.arg;
prosody.platform = "unknown";