lua-users home
lua-l archive

Re: Lua, testing whether a file exists...

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


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

AltStyle によって変換されたページ (->オリジナル) /