|
correction. On 12/18/06, Ken Smith <kgsmith@gmail.com> wrote:
I have found myself in a position where I must use Lua to walk a directory tree and performing some operation on every file. Is there an idiomatic way to do this in Lua? Ideally, I would like something like Python's os.walk(dir). Right now, I'm doing this. for file in io.popen('/usr/bin/find dir -type f') do
for file in io.popen('/usr/bin/find dir -type f'):lines() do
-- deal with file end This seems rather heavy-handed and a program that uses this construct runs out of memory although it is not yet clear if this construct is the cause. Thanks in advance for any suggestions. environment details: Darwin 8.8.1 (Mac OS X 10.4.8) Lua 5.1.1 Ken Smith