[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lua, testing whether a file exists...
- From: The Doctor <the_doctor@...>
- Date: Wed, 1 Sep 2004 15:13:09 +0100
That's just the problem, no amount of coding will ever get me out of it if Lua throws a terminal error and refuses to run further. Unless I can do the sort of thing a Psion Organiser does, a 'trap' keyword to precede the attempt that might cause an error, allowing the immediately following code to override the default, I can see no way to do anything except spoonfeed it the file it's looking for, or watch it drop out in total shutdown. :)
Rob Kendrick <lua-l@nun.org.uk> wrote:
(01/09/2004 15:13)
>
>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