diff options
author | Rob Kendrick (humdrum) <rjek@rjek.com> | 2012-05-01 13:21:30 +0100 |
---|---|---|
committer | Rob Kendrick (humdrum) <rjek@rjek.com> | 2012-05-01 13:21:30 +0100 |
commit | 80f2a14a42dfff407f87e09e05d816d8d6adf90d (patch) | |
tree | e85a31ea71e4b30663f44a98c7347cff6072dc5c /luxio.c | |
parent | c03a9d5ca256e89f89fe59d8b30a0b93c2fee844 (diff) | |
download | luxio-80f2a14a42dfff407f87e09e05d816d8d6adf90d.tar.gz |
Bind chmod() and fchmod()
Diffstat (limited to 'luxio.c')
-rw-r--r-- | luxio.c | 26 |
1 files changed, 26 insertions, 0 deletions
@@ -346,6 +346,30 @@ luxio_umask(lua_State *L) return 1; } +static int +luxio_chmod(lua_State *L) +{ + const char *path = luaL_checkstring(L, 1); + mode_t mode = luaL_checkinteger(L, 2); + + lua_pushinteger(L, chmod(path, mode)); + lua_pushinteger(L, errno); + + return 2; +} + +static int +luxio_fchmod(lua_State *L) +{ + int fd = luaL_checkinteger(L, 1); + mode_t mode = luaL_checkinteger(L, 2); + + lua_pushinteger(L, fchmod(fd, mode)); + lua_pushinteger(L, errno); + + return 2; +} + #define LUXIO_SOCKADDR_METATABLE_NAME "luxio.sockaddr" #ifndef UNIX_PATH_MAX /* From man 7 unix */ @@ -1590,6 +1614,8 @@ luxio_functions[] = { #endif { "fcntl", luxio_fcntl }, { "umask", luxio_umask }, + { "chmod", luxio_chmod }, + { "fchmod", luxio_fchmod }, { "mkfifo", luxio_mkfifo }, { "socket", luxio_socket }, |