+end
+
+function get_mods(path,retval,modpack)
+ local mods = core.get_dir_list(path, true)
+
+ for _, name in ipairs(mods) do
+ if name:sub(1, 1) ~= "." then
+ local prefix = path .. DIR_DELIM .. name
+ local toadd = {
+ dir_name = name,
+ parent_dir = path,
+ }
+ retval[#retval + 1] = toadd
+
+ -- Get config file
+ local mod_conf
+ local modpack_conf = io.open(prefix .. DIR_DELIM .. "modpack.conf")
+ if modpack_conf then
+ toadd.is_modpack = true
+ modpack_conf:close()
+
+ mod_conf = Settings(prefix .. DIR_DELIM .. "modpack.conf"):to_table()
+ if mod_conf.name then
+ name = mod_conf.name
+ toadd.is_name_explicit = true
+ end
+ else
+ mod_conf = Settings(prefix .. DIR_DELIM .. "mod.conf"):to_table()
+ if mod_conf.name then
+ name = mod_conf.name
+ toadd.is_name_explicit = true
+ end
+ end
+
+ -- Read from config
+ toadd.name = name
+ toadd.author = mod_conf.author
+ toadd.release = tonumber(mod_conf.release) or 0
+ toadd.path = prefix
+ toadd.type = "mod"
+
+ -- Check modpack.txt
+ -- Note: modpack.conf is already checked above
+ local modpackfile = io.open(prefix .. DIR_DELIM .. "modpack.txt")
+ if modpackfile then
+ modpackfile:close()
+ toadd.is_modpack = true
+ end
+
+ -- Deal with modpack contents
+ if modpack and modpack ~= "" then
+ toadd.modpack = modpack
+ elseif toadd.is_modpack then
+ toadd.type = "modpack"
+ toadd.is_modpack = true
+ get_mods(prefix, retval, name)
+ end
+ end
+ end
+end
+
+--modmanager implementation
+pkgmgr = {}
+
+function pkgmgr.get_texture_packs()
+ local txtpath = core.get_texturepath()
+ local txtpath_system = core.get_texturepath_share()
+ local retval = {}
+
+ load_texture_packs(txtpath, retval)
+ -- on portable versions these two paths coincide. It avoids loading the path twice
+ if txtpath ~= txtpath_system then
+ load_texture_packs(txtpath_system, retval)
+ end