Software /
code /
prosody
Comparison
plugins/mod_storage_xep0227.lua @ 6697:3d27f5855f4b
mod_storage_xep0227: Use configured storage path
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 15 May 2015 15:16:03 +0200 |
parent | 6696:6d717795708a |
child | 6698:95a8aeca1fc9 |
comparison
equal
deleted
inserted
replaced
6696:6d717795708a | 6697:3d27f5855f4b |
---|---|
5 local next = next; | 5 local next = next; |
6 local t_remove = table.remove; | 6 local t_remove = table.remove; |
7 local os_remove = os.remove; | 7 local os_remove = os.remove; |
8 local io_open = io.open; | 8 local io_open = io.open; |
9 | 9 |
10 local paths = require"util.paths"; | |
10 local st = require "util.stanza"; | 11 local st = require "util.stanza"; |
11 local parse_xml_real = require "util.xml".parse; | 12 local parse_xml_real = require "util.xml".parse; |
12 | 13 |
13 local function getXml(user, host) | 14 local function getXml(user, host) |
14 local jid = user.."@"..host; | 15 local jid = user.."@"..host; |
15 local path = "data/"..jid..".xml"; | 16 local path = paths.join(prosody.paths.data, jid..".xml"); |
16 local f = io_open(path); | 17 local f = io_open(path); |
17 if not f then return; end | 18 if not f then return; end |
18 local s = f:read("*a"); | 19 local s = f:read("*a"); |
19 return parse_xml_real(s); | 20 return parse_xml_real(s); |
20 end | 21 end |
21 local function setXml(user, host, xml) | 22 local function setXml(user, host, xml) |
22 local jid = user.."@"..host; | 23 local jid = user.."@"..host; |
23 local path = "data/"..jid..".xml"; | 24 local path = paths.join(prosody.paths.data, jid..".xml"); |
24 if xml then | 25 if xml then |
25 local f = io_open(path, "w"); | 26 local f = io_open(path, "w"); |
26 if not f then return; end | 27 if not f then return; end |
27 local s = tostring(xml); | 28 local s = tostring(xml); |
28 f:write(s); | 29 f:write(s); |