Software /
code /
prosody
Comparison
util/datamanager.lua @ 4452:7de17ca4de14
util/datamanager: Use package.config to figure out directory seperator
author | James Callahan <james@chatid.com> |
---|---|
date | Mon, 12 Dec 2011 17:08:48 +1100 |
parent | 4112:09f0ba0cfbfc |
child | 4993:5243b74a4cbb |
child | 5021:85b2689dbcfe |
comparison
equal
deleted
inserted
replaced
4451:70275ab52ab2 | 4452:7de17ca4de14 |
---|---|
1 -- Prosody IM | 1 -- Prosody IM |
2 -- Copyright (C) 2008-2010 Matthew Wild | 2 -- Copyright (C) 2008-2010 Matthew Wild |
3 -- Copyright (C) 2008-2010 Waqas Hussain | 3 -- Copyright (C) 2008-2010 Waqas Hussain |
4 -- | 4 -- |
5 -- This project is MIT/X11 licensed. Please see the | 5 -- This project is MIT/X11 licensed. Please see the |
6 -- COPYING file in the source package for more information. | 6 -- COPYING file in the source package for more information. |
7 -- | 7 -- |
8 | 8 |
9 | 9 |
18 local tostring, tonumber = tostring, tonumber; | 18 local tostring, tonumber = tostring, tonumber; |
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 = assert ( package.config:match ( "^([^\n]+)" ) , "package.config not in standard form" ) -- Extract directory seperator from package.config (an undocumented string that comes with lua) |
24 local lfs = require "lfs"; | 24 local lfs = require "lfs"; |
25 local prosody = prosody; | 25 local prosody = prosody; |
26 local raw_mkdir; | 26 local raw_mkdir; |
27 | 27 |
28 if prosody.platform == "posix" then | 28 if prosody.platform == "posix" then |
70 local function callback(username, host, datastore, data) | 70 local function callback(username, host, datastore, data) |
71 for _, f in ipairs(callbacks) do | 71 for _, f in ipairs(callbacks) do |
72 username, host, datastore, data = f(username, host, datastore, data); | 72 username, host, datastore, data = f(username, host, datastore, data); |
73 if username == false then break; end | 73 if username == false then break; end |
74 end | 74 end |
75 | 75 |
76 return username, host, datastore, data; | 76 return username, host, datastore, data; |
77 end | 77 end |
78 function add_callback(func) | 78 function add_callback(func) |
79 if not callbacks[func] then -- Would you really want to set the same callback more than once? | 79 if not callbacks[func] then -- Would you really want to set the same callback more than once? |
80 callbacks[func] = true; | 80 callbacks[func] = true; |