diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Handle.cc | 11 | ||||
-rw-r--r-- | lib/LuaHandle.cc | 13 |
2 files changed, 22 insertions, 2 deletions
diff --git a/lib/Handle.cc b/lib/Handle.cc index 685c4a4..7313d92 100644 --- a/lib/Handle.cc +++ b/lib/Handle.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id: Handle.cc,v 1.80 2007-05-30 11:57:09 pixel Exp $ */ +/* $Id: Handle.cc,v 1.81 2008-01-21 17:19:07 pixel Exp $ */ #include <stdio.h> #include <string.h> @@ -62,6 +62,8 @@ enum { INFLATE }; +int Handle::nb_handles = 0; + Handle::Handle(const Handle & nh) : itell(0), hFile(0), h(nh.h >= 0 ? nh.ndup() : nh.h), closed(nh.closed), nonblock(nh.closed), zfile(0), z(0), hMapObject(0), mapped(0) { #ifdef DEBUG @@ -70,6 +72,7 @@ Handle::Handle(const Handle & nh) : itell(0), hFile(0), h(nh.h >= 0 ? nh.ndup() if ((h >= 0) && (nh.z)) { SetZ(nh.z); } + nb_handles++; } Handle::~Handle() { @@ -77,6 +80,7 @@ Handle::~Handle() { printm(M_INFO, String(_("Destroying handle ")) + h + "\n"); #endif close(); + nb_handles--; } Handle::Handle(int nh) : itell(0), h(nh), closed(false), nonblock(false), zfile(0), z(0), hMapObject(0), mapped(0) @@ -84,6 +88,7 @@ Handle::Handle(int nh) : itell(0), h(nh), closed(false), nonblock(false), zfile( #ifdef DEBUG printm(M_INFO, String(_("Initialising handle ")) + h + "\n"); #endif + nb_handles++; } int Handle::GetHandle() { @@ -691,3 +696,7 @@ int Handle::ndup() const throw (GeneralException) { int Handle::nclose() throw (GeneralException) { return ::close(h); } + +int Handle::GetNbHandles() { + return nb_handles; +} diff --git a/lib/LuaHandle.cc b/lib/LuaHandle.cc index 587dabd..a1e5ccb 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.22 2007-05-30 11:57:10 pixel Exp $ */ +/* $Id: LuaHandle.cc,v 1.23 2008-01-21 17:19:07 pixel Exp $ */ #include "LuaHandle.h" @@ -63,6 +63,7 @@ class sLuaHandle : public Base { static int bseek(lua_State * L); static int btell(lua_State * L); static int exists(lua_State * L); + static int get_nb_handles(lua_State * L); private: static int read(lua_State * L, int); static int write(lua_State * L, int); @@ -480,6 +481,14 @@ int sLuaHandle::setz(lua_State * __L) { return 0; } +int sLuaHandle::get_nb_handles(lua_State * __L) { + Lua * L = Lua::find(__L); + + L->push((lua_Number) Handle::GetNbHandles()); + + return 1; +} + int sLuaHandle::seek(lua_State * __L) { Lua * L = Lua::find(__L); int n = L->gettop(); @@ -691,4 +700,6 @@ void LuaHandle::pushconstruct(Lua * L) { L->push("SEEK_END"); L->push((lua_Number) SEEK_END); L->settable(LUA_GLOBALSINDEX); + + L->declarefunc("get_nb_handles", sLuaHandle::get_nb_handles); } |