added getDirectoryItemsInfo

This commit is contained in:
Grump
2020-05-13 19:24:43 +02:00
parent ce371945a0
commit 81c8d8d3bf
3 changed files with 51 additions and 6 deletions

View File

@@ -317,6 +317,23 @@ function nativefs.getDirectoryItems(dir)
return result or {}
end
function nativefs.getDirectoryItemsInfo(path, filtertype)
local result, err = withTempMount(path, function(mount)
local items = {}
local files = love.filesystem.getDirectoryItems(mount)
for i = 1, #files do
local filepath = string.format('%s/%s', mount, files[i])
local info = love.filesystem.getInfo(filepath, filtertype)
if info then
info.name = files[i]
table.insert(items, info)
end
end
return items
end)
return result or {}
end
function nativefs.getInfo(path, filtertype)
local dir = path:match("(.*[\\/]).*$") or './'
local file = love.path.leaf(path)