[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Portably iterate over a directory
- From: Michael Pruemm <mpruemm@...>
- Date: Tue, 1 Dec 2009 12:02:28 +0100
-- This code works for me:
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"))