19 local error = error; |
19 local error = error; |
20 local next = next; |
20 local next = next; |
21 local t_insert = table.insert; |
21 local t_insert = table.insert; |
22 local append = require "util.serialization".append; |
22 local append = require "util.serialization".append; |
23 local path_separator = "/"; if os.getenv("WINDIR") then path_separator = "\\" end |
23 local path_separator = "/"; if os.getenv("WINDIR") then path_separator = "\\" end |
24 local lfs_mkdir = require "lfs".mkdir; |
24 local raw_mkdir; |
|
25 |
|
26 if prosody.platform == "posix" then |
|
27 raw_mkdir = require "util.pposix".mkdir; -- Doesn't trample on umask |
|
28 else |
|
29 raw_mkdir = require "lfs".mkdir; |
|
30 end |
25 |
31 |
26 module "datamanager" |
32 module "datamanager" |
27 |
33 |
28 ---- utils ----- |
34 ---- utils ----- |
29 local encode, decode; |
35 local encode, decode; |
30 do |
36 do |
31 local urlcodes = setmetatable({}, { __index = function (t, k) t[k] = char(tonumber("0x"..k)); return t[k]; end }); |
37 local urlcodes = setmetatable({}, { __index = function (t, k) t[k] = char(tonumber("0x"..k)); return t[k]; end }); |
32 |
38 |
33 decode = function (s) |
39 decode = function (s) |
34 return s and (s:gsub("+", " "):gsub("%%([a-fA-F0-9][a-fA-F0-9])", urlcodes)); |
40 return s and (s:gsub("+", " "):gsub("%%([a-fA-F0-9][a-fA-F0-9])", urlcodes)); |
35 end |
41 end |