From 41bcf415c4ba785357fbf97ca357f32598b13813 Mon Sep 17 00:00:00 2001 From: Jan Kneschke Date: Fri, 6 Oct 2006 11:21:00 +0000 Subject: [PATCH] added content-type to the .stat() and decoded the st_mode git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.4.x@1378 152afb58-edef-0310-8abb-c4023f1b3aa9 --- src/mod_magnet.c | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/src/mod_magnet.c b/src/mod_magnet.c index 100ec91b..3356647c 100644 --- a/src/mod_magnet.c +++ b/src/mod_magnet.c @@ -200,9 +200,28 @@ static int magnet_stat(lua_State *L) { } lua_newtable(L); - lua_pushinteger(L, sce->st.st_mode); - lua_setfield(L, -2, "st_mode"); + + lua_pushboolean(L, S_ISREG(sce->st.st_mode)); + lua_setfield(L, -2, "is_file"); + lua_pushboolean(L, S_ISDIR(sce->st.st_mode)); + lua_setfield(L, -2, "is_dir"); + + lua_pushboolean(L, S_ISCHR(sce->st.st_mode)); + lua_setfield(L, -2, "is_char"); + + lua_pushboolean(L, S_ISBLK(sce->st.st_mode)); + lua_setfield(L, -2, "is_block"); + + lua_pushboolean(L, S_ISSOCK(sce->st.st_mode)); + lua_setfield(L, -2, "is_socket"); + + lua_pushboolean(L, S_ISLNK(sce->st.st_mode)); + lua_setfield(L, -2, "is_link"); + + lua_pushboolean(L, S_ISFIFO(sce->st.st_mode)); + lua_setfield(L, -2, "is_fifo"); + lua_pushinteger(L, sce->st.st_mtime); lua_setfield(L, -2, "st_mtime"); @@ -234,6 +253,13 @@ static int magnet_stat(lua_State *L) { buffer_free(b); + if (!buffer_is_empty(sce->content_type)) { + lua_pushlstring(L, sce->content_type->ptr, sce->content_type->used - 1); + } else { + lua_pushnil(L); + } + lua_setfield(L, -2, "content-type"); + return 1; }