lua-users home
lua-l archive

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

function exists(fname)
        local f =, "r")
        if (f and f:read()) then return true end

This is probably not what you want: it'll leave the file open till the next GC closes the handle...

If you're serious about checking for file/directory existence (and such), you'd do well to look into Luiz' posix library. You can find it here:

Among other things it'll give you functions like "access" and "stat". These are more functional and in all likelihood more efficient as well.

no signature is a signature.