lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi Leo,

On Jun 26, 2009, at 1:22 AM, Leo Razoumov wrote:

Unfortunately, I do not see how one can close the directory explicitly
from Lua short of hacking lfs.c. The directory related userdata is
well hidden inside an upvalue accessible only to dir_iter.

Check the thread "lfs.dir, partial itineration and open file?" on the kepler mailing list.

Fabio Mascarenhas has added such close method to the directory iterator:

"This is now in luafilesystem cvs, although in slightly modified form:
local iter, dir_obj = lfs.dir(path)

local entry = iter(dir_obj) -- iterates, used by generic for
local entry = dir_obj:next() -- iterares, same as iter(dir_obj)
dir_obj:close() -- for explicitly closing the object before iteration
finishes"

--
PA.
http://alt.textdrive.com/nanoki/