使用Corona和Lua遍历目录中的所有文件

Let*_*yer 1 filesystems lua file coronasdk

在Corona SDK中是否可以获取目录中所有文件的列表?假设我有变量resourceDir = system.ResourceDirectory,我将如何遍历resourceDir中的所有文件?

McS*_*tch 5

这个功能刚刚添加了Corona,包括LuaFileSystem模块:

local lfs = require "lfs"

local doc_path = system.pathForFile( "", system.DocumentsDirectory )

for file in lfs.dir(doc_path) do
    -- file is the current file or directory name
    print( "Found file: " .. file )
end
Run Code Online (Sandbox Code Playgroud)

更多信息:http: //blog.anscamobile.com/2012/05/luafilesystem-lfs-tutorial/