1
0
Fork 0
forked from len0rd/rockbox

lua add a way to filter settings on read

rather than dumping all the settings allow a filter function
to choose desired settings

in menucoresettings you can see an how to do exact text matches
or wilcard matches you can even use luas version of regex

Change-Id: I4c7f7592498ea194e06e9a556b77ffd57f5d4223
This commit is contained in:
William Wilgus 2021-05-19 23:29:10 -04:00
parent dcff9b85a3
commit e910f63bba
2 changed files with 17 additions and 8 deletions

View file

@ -151,12 +151,15 @@ function rb.settings.read(s_settings, s_var, s_groupname)
return data
end
function rb.settings.dump(s_settings, s_groupname, s_structname, t_output)
function rb.settings.dump(s_settings, s_groupname, s_structname, t_output, fn_filter)
t_output = t_output or {}
fn_filter = fn_filter or function(s,k) return true end
local tgroup = rb[s_groupname]
s_structname = s_structname or s_settings
for k, v in pairs(tgroup[s_structname]) do
t_output[k] = rb.settings.read(s_settings, v, s_groupname)
if fn_filter(s_structname, k) then
t_output[k] = rb.settings.read(s_settings, v, s_groupname)
end
end
return t_output
end