- local f, err = io.open(file);
- if f then
- local data = f:read("*a");
- local ok, err = parsers.lua.load(data, file);
- if not ok then error(err:gsub("%[string.-%]", file), 0); end
+ if file:match("[*?]") then
+ local path_pos, glob = file:match("()([^"..path_sep.."]+)$");
+ local path = file:sub(1, math_max(path_pos-2,0));
+ local config_path = config_file:gsub("[^"..path_sep.."]+$", "");
+ if #path > 0 then
+ path = resolve_relative_path(config_path, path);
+ else
+ path = config_path;
+ end
+ local patt = glob_to_pattern(glob);
+ for f in lfs.dir(path) do
+ if f:sub(1,1) ~= "." and f:match(patt) then
+ env.Include(path..path_sep..f);
+ end
+ end
+ else
+ local file = resolve_relative_path(config_file:gsub("[^"..path_sep.."]+$", ""), file);
+ local f, err = io.open(file);
+ if f then
+ local ret, err = parsers.lua.load(f:read("*a"), file, config);
+ if not ret then error(err:gsub("%[string.-%]", file), 0); end
+ end
+ if not f then error("Error loading included "..file..": "..err, 0); end
+ return f, err;