[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:28:42 +0100
Thankyou.
That works.
I was using io.open within another function and overlooked the effect that was having..
(F=assert(io.open(F,"rb")))
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 <mroth@nessie.de> wrote:
(01/09/2004 15:18)
>
>-----BEGIN PGP SIGNED MESSAGE-----
>Hash: SHA1
>
>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
> io.close(file)
> return true
> else
> return false
> end
> end
>
>
>| 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
>
>iD8DBQFBNdobSIrOxc3jOmoRAi3SAJ4h9UmBF1LCyre7ebbu4JUmfzF47wCfbnzl
>rsqh5uCwPVchZb6FyVn1Mmo=
>=Pa9/
>-----END PGP SIGNATURE-----