Comparison

core/configmanager.lua @ 6166:46cb87d531a7

configmanager: Delay importing LuaFileSystem until needed by an Include line
author Kim Alvefur <zash@zash.se>
date Fri, 09 May 2014 19:59:49 +0200
parent 5811:27ae988f5b70
child 6167:5af7fe1014db
child 6323:5926f01e5cd2
comparison
equal deleted inserted replaced
6155:dc3497041aca 6166:46cb87d531a7
12 local format, math_max = string.format, math.max; 12 local format, math_max = string.format, math.max;
13 13
14 local fire_event = prosody and prosody.events.fire_event or function () end; 14 local fire_event = prosody and prosody.events.fire_event or function () end;
15 15
16 local envload = require"util.envload".envload; 16 local envload = require"util.envload".envload;
17 local lfs = require "lfs"; 17 local deps = require"util.dependencies";
18 local path_sep = package.config:sub(1,1); 18 local path_sep = package.config:sub(1,1);
19 19
20 module "configmanager" 20 module "configmanager"
21 21
22 local parsers = {}; 22 local parsers = {};
212 end 212 end
213 env.component = env.Component; 213 env.component = env.Component;
214 214
215 function env.Include(file) 215 function env.Include(file)
216 if file:match("[*?]") then 216 if file:match("[*?]") then
217 local lfs = deps.softreq "lfs";
218 if not lfs then
219 error(format("Error expanding wildcard pattern in Include %q - LuaFileSystem not available", file));
220 end
217 local path_pos, glob = file:match("()([^"..path_sep.."]+)$"); 221 local path_pos, glob = file:match("()([^"..path_sep.."]+)$");
218 local path = file:sub(1, math_max(path_pos-2,0)); 222 local path = file:sub(1, math_max(path_pos-2,0));
219 local config_path = config_file:gsub("[^"..path_sep.."]+$", ""); 223 local config_path = config_file:gsub("[^"..path_sep.."]+$", "");
220 if #path > 0 then 224 if #path > 0 then
221 path = resolve_relative_path(config_path, path); 225 path = resolve_relative_path(config_path, path);