Software /
code /
prosody
Comparison
core/configmanager.lua @ 1000:a73715a9267f
core.configmanager: Fire event when (re)loading config file
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Fri, 17 Apr 2009 16:14:20 +0100 |
parent | 913:3e2dac84017d |
child | 1504:9d8c35e98ca2 |
comparison
equal
deleted
inserted
replaced
999:c088139d8f05 | 1000:a73715a9267f |
---|---|
9 | 9 |
10 | 10 |
11 local _G = _G; | 11 local _G = _G; |
12 local setmetatable, loadfile, pcall, rawget, rawset, io, error, dofile, type = | 12 local setmetatable, loadfile, pcall, rawget, rawset, io, error, dofile, type = |
13 setmetatable, loadfile, pcall, rawget, rawset, io, error, dofile, type; | 13 setmetatable, loadfile, pcall, rawget, rawset, io, error, dofile, type; |
14 | |
15 local eventmanager = require "core.eventmanager"; | |
14 | 16 |
15 module "configmanager" | 17 module "configmanager" |
16 | 18 |
17 local parsers = {}; | 19 local parsers = {}; |
18 | 20 |
66 if parsers[format] and parsers[format].load then | 68 if parsers[format] and parsers[format].load then |
67 local f, err = io.open(filename); | 69 local f, err = io.open(filename); |
68 if f then | 70 if f then |
69 local ok, err = parsers[format].load(f:read("*a")); | 71 local ok, err = parsers[format].load(f:read("*a")); |
70 f:close(); | 72 f:close(); |
73 if ok then | |
74 eventmanager.fire_event("config-reloaded", { filename = filename, format = format }); | |
75 end | |
71 return ok, "parser", err; | 76 return ok, "parser", err; |
72 end | 77 end |
73 return f, "file", err; | 78 return f, "file", err; |
74 end | 79 end |
75 | 80 |