[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Lua, testing whether a file exists...
- From: The Doctor <the_doctor@...>
- Date: Wed, 1 Sep 2004 15:28:42 +0100
I was using io.open within another function and overlooked the effect that was having..
It works fine with the file there, and I'd forgotten that io.open wasn't being tested directly anymore..
Sorry everyone, too many hours don't help me think well.
Michael Roth <email@example.com> wrote:
>-----BEGIN PGP SIGNED MESSAGE-----
>The Doctor wrote:
>| Please can someone tell me if Lua can tell if a file exists?
> function exists(filename)
> local file = io.open(filename)
> if file then
> return true
> return false
>| 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...
>-----BEGIN PGP SIGNATURE-----
>Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
>-----END PGP SIGNATURE-----