Comparison

util/pluginloader.lua @ 4152:4d52812d018d

util.pluginloader: Remove unused support for custom loaders, to simplify further refactoring.
author Waqas Hussain <waqas20@gmail.com>
date Sun, 20 Feb 2011 20:11:52 +0500
parent 4150:2894ca33ec45
child 4154:3785a9bb7f11
comparison
equal deleted inserted replaced
4151:a1ac8f064dcb 4152:4d52812d018d
30 local content = file:read("*a"); 30 local content = file:read("*a");
31 file:close(); 31 file:close();
32 return content, path; 32 return content, path;
33 end 33 end
34 34
35 function load_resource(plugin, resource, loader) 35 function load_resource(plugin, resource)
36 local path, name = plugin:match("([^/]*)/?(.*)"); 36 local path, name = plugin:match("([^/]*)/?(.*)");
37 if name == "" then 37 if name == "" then
38 if not resource then 38 if not resource then
39 resource = "mod_"..plugin..".lua"; 39 resource = "mod_"..plugin..".lua";
40 end 40 end
41 loader = loader or load_file;
42 41
43 local content, err = loader(plugin.."/"..resource); 42 local content, err = load_file(plugin.."/"..resource);
44 if not content then content, err = loader(resource); end 43 if not content then content, err = load_file(resource); end
45 -- TODO add support for packed plugins
46 44
47 return content, err; 45 return content, err;
48 else 46 else
49 if not resource then 47 if not resource then
50 resource = "mod_"..name..".lua"; 48 resource = "mod_"..name..".lua";
51 end 49 end
52 loader = loader or load_file;
53 50
54 local content, err = loader(plugin.."/"..resource); 51 local content, err = load_file(plugin.."/"..resource);
55 if not content then content, err = loader(path.."/"..resource); end 52 if not content then content, err = load_file(path.."/"..resource); end
56 -- TODO add support for packed plugins
57 53
58 return content, err; 54 return content, err;
59 end 55 end
60 end 56 end
61 57