annotate framework/env/execute/_create_sorted_execution_list.lua @ 206:eb3e236d261d
Code cleanup and work on Moonbridge integration
author |
jbe |
date |
Fri Jan 09 22:28:39 2015 +0100 (2015-01-09) |
parents |
framework/env/execute/_add_filters_by_path.lua@a54cc7dcabf1 |
children |
17baf126ea88 |
rev |
line source |
jbe@206
|
1 function execute._create_sorted_execution_list(add_paths, execute_func)
|
jbe@206
|
2 local entries = {}
|
jbe@206
|
3 add_paths(function(...)
|
jbe@206
|
4 local full_path = encode.file_path(WEBMCP_BASE_PATH, "app", ...)
|
jbe@206
|
5 local relative_path = encode.file_path("", ...)
|
jbe@206
|
6 local filenames = extos.listdir(full_path)
|
jbe@206
|
7 if filenames then
|
jbe@206
|
8 table.sort(filenames) -- not really neccessary, due to sorting afterwards
|
jbe@206
|
9 for i, filename in ipairs(filenames) do
|
jbe@206
|
10 if string.find(filename, "%.lua$") then
|
jbe@206
|
11 if entries[filename] then
|
jbe@206
|
12 error('More than one filter or initializer is named "' .. filter_name .. '".')
|
jbe@206
|
13 end
|
jbe@206
|
14 entries[#entries+1] = filename
|
jbe@206
|
15 entries[filename] = function()
|
jbe@206
|
16 execute_func(
|
jbe@206
|
17 encode.file_path(full_path, filename),
|
jbe@206
|
18 encode.file_path(relative_path, filename)
|
jbe@206
|
19 )
|
jbe@206
|
20 end
|
jbe/bsw@0
|
21 end
|
jbe/bsw@0
|
22 end
|
jbe/bsw@0
|
23 end
|
jbe@206
|
24 end)
|
jbe@206
|
25 table.sort(entries)
|
jbe@206
|
26 for idx, filename in ipairs(entries) do
|
jbe@206
|
27 entries[idx] = enteries[filename]
|
jbe@206
|
28 entries[filename] = nil
|
jbe/bsw@0
|
29 end
|
jbe@206
|
30 return entries
|
jbe/bsw@0
|
31 end
|