]> granicus.if.org Git - apache/commitdiff
Added new r:touch() function; updated docs.
authorGuenter Knauf <fuankg@apache.org>
Tue, 25 Jun 2013 14:19:51 +0000 (14:19 +0000)
committerGuenter Knauf <fuankg@apache.org>
Tue, 25 Jun 2013 14:19:51 +0000 (14:19 +0000)
(Backport r1495270, r1495665, r1495666)

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1496483 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
docs/manual/mod/mod_lua.xml
modules/lua/lua_request.c

diff --git a/CHANGES b/CHANGES
index b1d3212c786a993164b9c9e3d17cd2fb55b79f14..4aa95c2627070bd56c7e76784088a58949a506c0 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -25,8 +25,8 @@ Changes with Apache 2.4.5
 
   *) mod_remoteip: close file in error path. [Christophe Jaillet]
 
-  *) mod_lua: Add some new functions: r:htpassword(), r:mkdir(), r:rmdir(),
-     r:get_direntries(), r.date_parse_rfc().
+  *) mod_lua: Add some new functions: r:htpassword(), r:mkdir(), r:mkrdir(),
+     r:rmdir(), r:touch(), r:get_direntries(), r.date_parse_rfc().
      [Guenter Knauf]
 
   *) mod_lua: Sync 2.4 branch with trunk. This includes (but is not limited to)
index a1f4584d8bbaf12fbeb85cd3bf9dd564473dd6d3..5bbe7a76bae798983ba4d7fd4ea8b58ba9e32f80 100644 (file)
@@ -935,10 +935,18 @@ r:htpassword(string [,algorithm [,cost]]) -- Creates a password hash from a stri
 r:mkdir(dir [,mode]) -- Creates a directory and sets mode to optional mode paramter.
 </highlight>
 
+<highlight language="lua">
+r:mkrdir(dir [,mode]) -- Creates directories recursive and sets mode to optional mode paramter.
+</highlight>
+
 <highlight language="lua">
 r:rmdir(dir) -- Removes a directory.
 </highlight>
 
+<highlight language="lua">
+r:touch([mtime]) -- Sets the file modification time to current time or to optional mtime msec value.
+</highlight>
+
 <highlight language="lua">
 r:get_direntries(dir) -- Returns a table with all directory entries.
 
index 66cbb1ca4e40a7019f53ee64beb2542a19782d36..c2cfb5354872ccdea1cfda20197fdb3390d91642 100644 (file)
@@ -871,6 +871,25 @@ static int lua_apr_htpassword(lua_State *L)
     return 1;
 }
 
+/*
+ * 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
  */
@@ -2153,6 +2172,8 @@ void ap_lua_load_request_lmodule(lua_State *L, apr_pool_t *p)
                  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,