From 15b0e9849e3830eefc6c98aa7d0858981a0318b5 Mon Sep 17 00:00:00 2001 From: Pixel Date: Sun, 8 Nov 2009 20:26:30 -0800 Subject: Adding the ability to open archives from Lua. --- lib/LuaHandle.cc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'lib/LuaHandle.cc') diff --git a/lib/LuaHandle.cc b/lib/LuaHandle.cc index ce6d48c..376e485 100644 --- a/lib/LuaHandle.cc +++ b/lib/LuaHandle.cc @@ -77,6 +77,7 @@ class sLuaHandle : public Base { static int ucl_decompress(lua_State * L); static int ucl_overlap(lua_State * L); #endif + static int archive(lua_State * L); private: static int read(lua_State * L, int); static int write(lua_State * L, int); @@ -658,6 +659,19 @@ int sLuaHandle::ucl_overlap(lua_State * __L) { } #endif +int sLuaHandle::archive(lua_State * __L) { + Lua * L = Lua::find(__L); + int n = L->gettop(); + + if ((n != 1) || !L->isstring(1)) { + L->error("Archive needs exactly one string argument."); + } + + new Archive(L->tostring(1)); + + return 0; +} + int sLuaHandle::seek(lua_State * __L) { Lua * L = Lua::find(__L); int n = L->gettop(); @@ -901,4 +915,6 @@ void LuaHandle::pushconstruct(Lua * L) { L->declarefunc("ucl_decompress", sLuaHandle::ucl_decompress); L->declarefunc("ucl_overlap", sLuaHandle::ucl_overlap); #endif + + L->declarefunc("Archive", sLuaHandle::archive); } -- cgit v1.2.3