httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fua...@apache.org
Subject svn commit: r1495270 - /httpd/httpd/trunk/modules/lua/lua_request.c
Date Fri, 21 Jun 2013 01:51:45 GMT
Author: fuankg
Date: Fri Jun 21 01:51:45 2013
New Revision: 1495270

URL: http://svn.apache.org/r1495270
Log:
Added new r:touch() function.

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=1495270&r1=1495269&r2=1495270&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/lua/lua_request.c (original)
+++ httpd/httpd/trunk/modules/lua/lua_request.c Fri Jun 21 01:51:45 2013
@@ -872,6 +872,25 @@ static int lua_apr_htpassword(lua_State 
 }
 
 /*
+ * lua_apr_touch; r:touch(string [, time]) - Sets mtime of a file
+ */
+static int lua_apr_touch(lua_State *L)
+{
+    request_rec     *r;
+    const char      *path;
+    apr_status_t    status;
+    apr_time_t      mtime;
+
+    r = ap_lua_check_request_rec(L, 1);
+    luaL_checktype(L, 2, LUA_TSTRING);
+    path = lua_tostring(L, 2);
+    mtime = luaL_optnumber(L, 3, apr_time_now());
+    status = apr_file_mtime_set(path, mtime, r->pool);
+    lua_pushboolean(L, (status == 0));
+    return 1;
+}
+
+/*
  * lua_apr_mkdir; r:mkdir(string [, permissions]) - Creates a directory
  */
 static int lua_apr_mkdir(lua_State *L)
@@ -2153,6 +2172,8 @@ void ap_lua_load_request_lmodule(lua_Sta
                  makefun(&lua_apr_sha1, APL_REQ_FUNTYPE_LUACFUN, p));
     apr_hash_set(dispatch, "htpassword", APR_HASH_KEY_STRING,
                  makefun(&lua_apr_htpassword, APL_REQ_FUNTYPE_LUACFUN, p));
+    apr_hash_set(dispatch, "touch", APR_HASH_KEY_STRING,
+                 makefun(&lua_apr_touch, APL_REQ_FUNTYPE_LUACFUN, p));
     apr_hash_set(dispatch, "mkdir", APR_HASH_KEY_STRING,
                  makefun(&lua_apr_mkdir, APL_REQ_FUNTYPE_LUACFUN, p));
     apr_hash_set(dispatch, "mkrdir", APR_HASH_KEY_STRING,



Mime
View raw message