Page 1 of 1

looking for examples of how to use love.filesystem.getInfo()

Posted: Tue Nov 17, 2020 9:20 am
by rd_
Hi, I'm trying to update some examples of the recursiveEnumerate function found on the BYTEPATH tutorial and also on the love wiki. I got a message that love.filesystem.isFile and love.filesystem.isDirectory have been replaced with love.filesystem.getInfo
Using the wiki, I couldn't figure out how to differentiate a file from a folder, but searching around the forums I think I found a way. Is there another place I can look for examples of love.filesystem.getInfo? These are the examples that I clipped:

Code: Select all

love.filesystem.getInfo(file, 'file')
love.filesystem.getInfo(file, 'directory')
This is the code that I'm trying to update, can't tell if I did it correctly though because I'm still learning and there are probably some errors elsewhere in my main.lua:

Code: Select all

function recursiveEnumerate(folder, fileTree)
    local filesTable = love.filesystem.getDirectoryItems(folder)
    for i,v in ipairs(filesTable) do
        local file = folder..'.'..v
        if love.filesystem.getInfo(file, 'file') then
            table.insert(fileTree, file)
        elseif love.filesystem.getInfo(file, 'directory') then
            recursiveEnumerate(file, fileTree)
        end
    end
end

Re: looking for examples of how to use love.filesystem.getInfo()

Posted: Tue Nov 17, 2020 12:49 pm
by zorg
yep, from a first glance that should be indeed how it works now. :3