Software /
code /
prosody
Changeset
499:29f165027f07
Merge from waqas
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sun, 30 Nov 2008 01:02:12 +0000 |
parents | 497:a2ccfabfda82 (current diff) 498:0862416befe3 (diff) |
children | 500:6468ea154296 |
files | |
diffstat | 1 files changed, 25 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/prosody Sun Nov 30 00:38:41 2008 +0000 +++ b/prosody Sun Nov 30 01:02:12 2008 +0000 @@ -56,7 +56,30 @@ end end -require "util.datamanager".set_data_path(config.get("*", "core", "data_path") or "data"); +local data_path = config.get("*", "core", "data_path") or "data"; +local path_separator = "/"; if os.getenv("WINDIR") then path_separator = "\\" end +local _mkdir = {} +function mkdir(path) + path = path:gsub("/", path_separator); + --print("mkdir",path); + local x = io.popen("mkdir "..path.." 2>&1"):read("*a"); +end +function encode(s) return s and (s:gsub("%W", function (c) return string.format("%%%x", c:byte()); end)); end +function mkdirs(host) + if not _mkdir[host] then + local host_dir = string.format("%s/%s", data_path, encode(host)); + mkdir(host_dir); + mkdir(host_dir.."/accounts"); + mkdir(host_dir.."/vcard"); + mkdir(host_dir.."/roster"); + mkdir(host_dir.."/private"); + mkdir(host_dir.."/offline"); + _mkdir[host] = true; + end +end +mkdir(data_path); + +require "util.datamanager".set_data_path(data_path); local server = require "net.server" @@ -71,6 +94,7 @@ for host, host_config in pairs(defined_hosts) do if host ~= "*" and (host_config.core.enabled == nil or host_config.core.enabled) then hosts[host] = {type = "local", connected = true, sessions = {}, host = host, s2sout = {} }; + mkdirs(data_path.."/"..host); end end