Return-Path: X-Original-To: apmail-httpd-cvs-archive@www.apache.org Delivered-To: apmail-httpd-cvs-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3015310162 for ; Sat, 1 Jun 2013 07:47:58 +0000 (UTC) Received: (qmail 63957 invoked by uid 500); 1 Jun 2013 07:47:56 -0000 Delivered-To: apmail-httpd-cvs-archive@httpd.apache.org Received: (qmail 63034 invoked by uid 500); 1 Jun 2013 07:47:54 -0000 Mailing-List: contact cvs-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@httpd.apache.org list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list cvs@httpd.apache.org Received: (qmail 61363 invoked by uid 99); 1 Jun 2013 07:47:52 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 01 Jun 2013 07:47:52 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 01 Jun 2013 07:47:50 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 0314F2388847; Sat, 1 Jun 2013 07:47:30 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1488480 - /httpd/httpd/trunk/modules/lua/lua_request.c Date: Sat, 01 Jun 2013 07:47:29 -0000 To: cvs@httpd.apache.org From: fuankg@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20130601074730.0314F2388847@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: fuankg Date: Sat Jun 1 07:47:29 2013 New Revision: 1488480 URL: http://svn.apache.org/r1488480 Log: Added optional parameter wanted to r:stat(). Modified: httpd/httpd/trunk/modules/lua/lua_request.c Modified: httpd/httpd/trunk/modules/lua/lua_request.c URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/lua/lua_request.c?rev=1488480&r1=1488479&r2=1488480&view=diff ============================================================================== --- httpd/httpd/trunk/modules/lua/lua_request.c (original) +++ httpd/httpd/trunk/modules/lua/lua_request.c Sat Jun 1 07:47:29 2013 @@ -1243,42 +1243,53 @@ static int lua_ap_getdir(lua_State *L) } /* - * lua_ap_stat; r:stat(filename) - Runs stat on a file and returns the file - * info as a table + * lua_ap_stat; r:stat(filename [, wanted]) - Runs stat on a file and + * returns the file info as a table */ static int lua_ap_stat(lua_State *L) { request_rec *r; const char *filename; apr_finfo_t file_info; + apr_int32_t wanted; luaL_checktype(L, 1, LUA_TUSERDATA); luaL_checktype(L, 2, LUA_TSTRING); r = ap_lua_check_request_rec(L, 1); filename = lua_tostring(L, 2); - if (apr_stat(&file_info, filename, APR_FINFO_MIN, r->pool) == OK) { + wanted = luaL_optinteger(L, 3, APR_FINFO_MIN); + if (apr_stat(&file_info, filename, wanted, r->pool) == OK) { lua_newtable(L); - - lua_pushstring(L, "mtime"); - lua_pushnumber(L, (lua_Number) file_info.mtime); - lua_settable(L, -3); - - lua_pushstring(L, "atime"); - lua_pushnumber(L, (lua_Number) file_info.atime); - lua_settable(L, -3); - - lua_pushstring(L, "ctime"); - lua_pushnumber(L, (lua_Number) file_info.ctime); - lua_settable(L, -3); - - lua_pushstring(L, "size"); - lua_pushnumber(L, (lua_Number) file_info.size); - lua_settable(L, -3); - - lua_pushstring(L, "filetype"); - lua_pushinteger(L, file_info.filetype); - lua_settable(L, -3); - + if (wanted & APR_FINFO_MTIME) { + lua_pushstring(L, "mtime"); + lua_pushnumber(L, (lua_Number) file_info.mtime); + lua_settable(L, -3); + } + if (wanted & APR_FINFO_ATIME) { + lua_pushstring(L, "atime"); + lua_pushnumber(L, (lua_Number) file_info.atime); + lua_settable(L, -3); + } + if (wanted & APR_FINFO_CTIME) { + lua_pushstring(L, "ctime"); + lua_pushnumber(L, (lua_Number) file_info.ctime); + lua_settable(L, -3); + } + if (wanted & APR_FINFO_SIZE) { + lua_pushstring(L, "size"); + lua_pushnumber(L, (lua_Number) file_info.size); + lua_settable(L, -3); + } + if (wanted & APR_FINFO_TYPE) { + lua_pushstring(L, "filetype"); + lua_pushinteger(L, file_info.filetype); + lua_settable(L, -3); + } + if (wanted & APR_FINFO_PROT) { + lua_pushstring(L, "protection"); + lua_pushinteger(L, file_info.protection); + lua_settable(L, -3); + } return 1; } else {