从Lua目录中获取文件名
答
具体有以下几种可以修改为你想要做什么:
local dircmd = "find . -type f -print" -- default to Unix
if string.sub(package.config,1,1) == '\\' then
-- Windows
dircmd = "dir /b/s"
end
os.execute(dircmd .. " > zzfiles")
local luafiles = {}
for f in io.lines("zzfiles") do
if f:sub(-4) == ".lua" then
luafiles[#luafiles+1] = f
end
end
print(table.concat(luafiles, "\n"))
我不知道你问什么。你想获得目录中的文件列表吗? – 2011-04-07 18:25:52