lua-users home
lua-l archive

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


I have some code which does this under unix:

     local path = "/path/to/somewhere"
     local lfs = require("luafilesystem")
     local posix = require("posix")
     if (posix.access(path,"x")) then
        for f in lfs.dir(path) do
           ...
        end
     end

The problem is that between the posix.access() test and the lfs.dir() call the permissions on path could change.

What I would like instead is some way to ignore the error that lfs.dir() is causing.  Normally one can ignore errors with pcall() but I don't see how to use pcall with an iterator like lfs.dir().

Does anyone know how to do that?  To make the problem any harder, any solution must work with Lua 5.1+

Thanks,
Robert McLay