[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: walking a directory tree
- From: Javier Guerra <javier@...>
- Date: Mon, 18 Dec 2006 14:16:50 -0500
On Monday 18 December 2006 2:07 pm, Ken Smith 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
> -- 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.
check luafilesystem. you can either do your routine recursive (quick and
easy) or create a FIFO queue, so your code looks 'flat'. you can also create
an iterator that would do the recursion for you.
--
Javier
Attachment:
pgpQ1zCRh2mZO.pgp
Description: PGP signature