diff options
| -rw-r--r-- | lib/LuaHandle.cc | 26 | 
1 files changed, 25 insertions, 1 deletions
| diff --git a/lib/LuaHandle.cc b/lib/LuaHandle.cc index 5107766..3c7460d 100644 --- a/lib/LuaHandle.cc +++ b/lib/LuaHandle.cc @@ -17,7 +17,7 @@   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA   */ -/* $Id: LuaHandle.cc,v 1.12 2003-12-26 20:36:07 pixel Exp $ */ +/* $Id: LuaHandle.cc,v 1.13 2004-02-16 13:16:52 pixel Exp $ */  #include "LuaHandle.h" @@ -62,6 +62,7 @@ class sLuaHandle : public Base {      static int bnewindex(lua_State * L);      static int bseek(lua_State * L);      static int btell(lua_State * L); +    static int exists(lua_State * L);    private:      static int read(lua_State * L, int);      static int write(lua_State * L, int); @@ -591,6 +592,27 @@ int sLuaHandle::bseek(lua_State * _L) {      return 1;  } +int sLuaHandle::exists(lua_State * _L) { +    Lua * L = Lua::find(_L); +    int n = L->gettop(); +    bool r = true; +     +    if (n != 1) { +	L->error("Incorrect number of arguments to function exists"); +    } +     +    try { +	Input testing(L->tostring()); +    } +    catch (IOGeneral & e) { +	r = false; +    } +     +    L->push(r); +     +    return 1; +} +  void LuaInput::pushmembers(Lua * L) {      LuaHandle::pushmembers(L);  } @@ -641,6 +663,8 @@ void LuaHandle::pushmembers(Lua * L) {      pushit(L, "seek", sLuaHandle::seek);      pushit(L, "setz", sLuaHandle::setz); +     +    L->declarefunc("exists", sLuaHandle::exists);      L->push("SEEK_SET");      L->push((lua_Number) SEEK_SET); | 
