[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Lua, testing whether a file exists...
- From: Rob Kendrick <lua-l@...>
- Date: Wed, 01 Sep 2004 15:13:06 +0100
The Doctor wrote:
Please can someone tell me if Lua can tell if a file exists?
I've tried testing for for a valid return from io.open(), but if the file doesn't exist, Lua throws up a default error, never mind trying to run my own handling code...
The only fuction that I can find that even looks like it might help is io.type(), and that gets a nil even if the file does exist.
Redefine the error handling function while you do the check, or use a
protected call? Actually, has anybody implemented a try/catch/finally doobry
that'd make this kind of thing slightly nicer?
Rob Kendrick, Pepperfish Ltd. +44 (0)845 226 4146 www.pepperfish.net
PGP signed or encrypted mail welcome Key ID: 3651D17A