I have a set of configuration lua files that I keep in a specific directory of my project. I don’t want to have to manually require each one of these files every time I add a new one so I have a system that crawls through that directory and requires each lua file it finds. This works great in the simulator and on desktop builds but I am having trouble getting it to work with the HTML5 build. When my service crawls through the directory it just sees empty folders. Here is the code that normally accomplishes this task, it returns an array of paths to be used with require().
[lua]
local function getLuaFilesInFolder_R(path, cache)
local properPath = string.gsub(path, “[.]”, “/”)
local sysPath = system.pathForFile(properPath, system.ResourceDirectory)
for entry in lfs.dir(sysPath) do
local mode = lfs.attributes(sysPath … “/” … entry, “mode”)
if mode == “file” then
local name = string.match(entry, “(.*).lua”)
if name then
cache[#cache + 1] = path … “.” … name
end
elseif mode == “directory” then
if not string.match(entry, “^[.].*”) then
getLuaFilesInFolder_R(path … “.” … entry, cache)
end
end
end
return cache
end
local function getLuaFilesInFolder()
return getLuaFilesInFolder_R(“Config”, {})
end
[/lua]
Is there a way for this to work with the HTML5 build?