diff options
author | Wuzzy <wuzzy2@mail.ru> | 2020-03-06 20:19:14 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-06 20:19:14 +0000 |
commit | ce8cdc03337ac20b998620f2690eb76e5434ffb9 (patch) | |
tree | 7ddef6b915122cebc50815dbeb4599cf53369cea /builtin/mainmenu | |
parent | 9ca0b3739cbaceaa291ac5062ab219e0aa7c49cb (diff) | |
download | minetest-ce8cdc03337ac20b998620f2690eb76e5434ffb9.tar.gz minetest-ce8cdc03337ac20b998620f2690eb76e5434ffb9.tar.bz2 minetest-ce8cdc03337ac20b998620f2690eb76e5434ffb9.zip |
Cleanup global namespace pollution in builtin (#9451)
Diffstat (limited to 'builtin/mainmenu')
-rw-r--r-- | builtin/mainmenu/pkgmgr.lua | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/builtin/mainmenu/pkgmgr.lua b/builtin/mainmenu/pkgmgr.lua index 0ac697fdb..5b8807310 100644 --- a/builtin/mainmenu/pkgmgr.lua +++ b/builtin/mainmenu/pkgmgr.lua @@ -16,6 +16,62 @@ --51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -------------------------------------------------------------------------------- +local function get_last_folder(text,count) + local parts = text:split(DIR_DELIM) + + if count == nil then + return parts[#parts] + end + + local retval = "" + for i=1,count,1 do + retval = retval .. parts[#parts - (count-i)] .. DIR_DELIM + end + + return retval +end + +local function cleanup_path(temppath) + + local parts = temppath:split("-") + temppath = "" + for i=1,#parts,1 do + if temppath ~= "" then + temppath = temppath .. "_" + end + temppath = temppath .. parts[i] + end + + parts = temppath:split(".") + temppath = "" + for i=1,#parts,1 do + if temppath ~= "" then + temppath = temppath .. "_" + end + temppath = temppath .. parts[i] + end + + parts = temppath:split("'") + temppath = "" + for i=1,#parts,1 do + if temppath ~= "" then + temppath = temppath .. "" + end + temppath = temppath .. parts[i] + end + + parts = temppath:split(" ") + temppath = "" + for i=1,#parts,1 do + if temppath ~= "" then + temppath = temppath + end + temppath = temppath .. parts[i] + end + + return temppath +end + function get_mods(path,retval,modpack) local mods = core.get_dir_list(path, true) |