annotate framework/env/execute/_create_sorted_execution_list.lua @ 402:04172238d79b
Do not require "engine" field to be set for mondelefant.connect{...}; Fixed bugs in mondelefant.connect{...} that could have crashed Lua; Shortened Lua registry key for mondelefant library
author |
jbe |
date |
Wed Jan 06 02:39:50 2016 +0100 (2016-01-06) |
parents |
17baf126ea88 |
children |
d7814e6d0124 |
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@226
|
27 entries[idx] = entries[filename]
|
jbe@206
|
28 entries[filename] = nil
|
jbe/bsw@0
|
29 end
|
jbe@206
|
30 return entries
|
jbe/bsw@0
|
31 end
|