aboutsummaryrefslogtreecommitdiffstats
path: root/util/datamanager.lua
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2008-11-29 11:24:59 +0100
committerTobias Markmann <tm@ayena.de>2008-11-29 11:24:59 +0100
commitabf0d19152cbf880252435d2801d852ce0459df8 (patch)
treebfde55649a88754f29d5bdbd68d3d2817675d3e8 /util/datamanager.lua
parenta718775bd40db918564a31e90f4c17a98a4cecfc (diff)
parentdcf87bb7c912e4206aae1fd3c959d87e8f59242f (diff)
downloadprosody-abf0d19152cbf880252435d2801d852ce0459df8.tar.gz
prosody-abf0d19152cbf880252435d2801d852ce0459df8.zip
Forced merge.
Diffstat (limited to 'util/datamanager.lua')
-rw-r--r--util/datamanager.lua16
1 files changed, 10 insertions, 6 deletions
diff --git a/util/datamanager.lua b/util/datamanager.lua
index 80b35733..99eef9f3 100644
--- a/util/datamanager.lua
+++ b/util/datamanager.lua
@@ -3,7 +3,7 @@ local setmetatable, type = setmetatable, type;
local pairs, ipairs = pairs, ipairs;
local char = string.char;
local loadfile, setfenv, pcall = loadfile, setfenv, pcall;
-local log = log;
+local log = require "util.logger".init("datamanager");
local io_open = io.open;
local os_remove = os.remove;
local tostring, tonumber = tostring, tonumber;
@@ -17,14 +17,14 @@ local indent = function(f, i)
end
end
+local data_path = "data";
+
module "datamanager"
---- utils -----
local encode, decode;
-local log = function (type, msg) return log(type, "datamanager", msg); end
-
do
local urlcodes = setmetatable({}, { __index = function (t, k) t[k] = char(tonumber("0x"..k)); return t[k]; end });
@@ -70,14 +70,18 @@ end
------- API -------------
+function set_data_path(path)
+ data_path = path;
+end
+
function getpath(username, host, datastore, ext)
ext = ext or "dat";
if username then
- return format("data/%s/%s/%s.%s", encode(host), datastore, encode(username), ext);
+ return format("%s/%s/%s/%s.%s", data_path, encode(host), datastore, encode(username), ext);
elseif host then
- return format("data/%s/%s.%s", encode(host), datastore, ext);
+ return format("%s/%s/%s.%s", data_path, encode(host), datastore, ext);
else
- return format("data/%s.%s", datastore, ext);
+ return format("%s/%s.%s", data_path, datastore, ext);
end
end