[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Lua, testing whether a file exists...
- From: "Ashwin Hirschi" <deery@...>
- Date: Thu, 23 Sep 2004 05:40:02 +0200
local f = io.open(fname, "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.