Browse Source

added file_isdir

git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-merge-1.4.x@664 152afb58-edef-0310-8abb-c4023f1b3aa9
svn/tags/lighttpd-1.4.3
Jan Kneschke 16 years ago
parent
commit
e45388fc44
  1. 25
      src/mod_cml_funcs.c
  2. 1
      src/mod_cml_funcs.h
  3. 1
      src/mod_cml_lua.c

25
src/mod_cml_funcs.c

@ -162,6 +162,31 @@ int f_file_isreg(lua_State *L) {
return 1;
}
int f_file_isdir(lua_State *L) {
struct stat st;
int n = lua_gettop(L);
if (n != 1) {
lua_pushstring(L, "file_isreg: expected one argument");
lua_error(L);
}
if (!lua_isstring(L, 1)) {
lua_pushstring(L, "file_isreg: argument has to be a string");
lua_error(L);
}
if (-1 == stat(lua_tostring(L, 1), &st)) {
lua_pushnil(L);
return 1;
}
lua_pushnumber(L, S_ISDIR(st.st_mode));
return 1;
}
#ifdef HAVE_MEMCACHE_H
int f_memcache_exists(lua_State *L) {

1
src/mod_cml_funcs.h

@ -9,6 +9,7 @@
int f_crypto_md5(lua_State *L);
int f_file_mtime(lua_State *L);
int f_file_isreg(lua_State *L);
int f_file_isdir(lua_State *L);
int f_dir_files(lua_State *L);
int f_memcache_exists(lua_State *L);

1
src/mod_cml_lua.c

@ -166,6 +166,7 @@ int cache_parse_lua(server *srv, connection *con, plugin_data *p, buffer *fn) {
lua_register(L, "md5", f_crypto_md5);
lua_register(L, "file_mtime", f_file_mtime);
lua_register(L, "file_isreg", f_file_isreg);
lua_register(L, "file_isdir", f_file_isreg);
lua_register(L, "dir_files", f_dir_files);
#ifdef HAVE_MEMCACHE_H

Loading…
Cancel
Save