lua-users home
lua-l archive

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


-----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-----