aboutsummaryrefslogtreecommitdiff
path: root/src/lfs.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lfs.c')
-rw-r--r--src/lfs.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/lfs.c b/src/lfs.c
index c0ac046..c39e296 100644
--- a/src/lfs.c
+++ b/src/lfs.c
@@ -7,10 +7,11 @@
7** lfs.dir (path) 7** lfs.dir (path)
8** lfs.lock (fh, mode) 8** lfs.lock (fh, mode)
9** lfs.mkdir (path) 9** lfs.mkdir (path)
10** lfs.rmdir (path)
10** lfs.touch (filepath [, atime [, mtime]]) 11** lfs.touch (filepath [, atime [, mtime]])
11** lfs.unlock (fh) 12** lfs.unlock (fh)
12** 13**
13** $Id: lfs.c,v 1.21 2005/05/20 18:32:19 uid20006 Exp $ 14** $Id: lfs.c,v 1.22 2005/06/03 21:50:59 tuler Exp $
14*/ 15*/
15 16
16#include <errno.h> 17#include <errno.h>
@@ -250,6 +251,23 @@ static int make_dir (lua_State *L) {
250 return 1; 251 return 1;
251} 252}
252 253
254/*
255** Removes a directory.
256** @param #1 Directory path.
257*/
258static int remove_dir (lua_State *L) {
259 const char *path = luaL_checkstring (L, 1);
260 int fail;
261
262 fail = rmdir (path);
263
264 lua_pushboolean (L, !fail);
265 if (fail) {
266 lua_pushfstring (L, "%s", strerror(errno));
267 return 2;
268 }
269 return 1;
270}
253 271
254/* 272/*
255** Directory iterator 273** Directory iterator
@@ -519,6 +537,7 @@ static const struct luaL_reg fslib[] = {
519 {"dir", dir_iter_factory}, 537 {"dir", dir_iter_factory},
520 {"lock", file_lock}, 538 {"lock", file_lock},
521 {"mkdir", make_dir}, 539 {"mkdir", make_dir},
540 {"rmdir", remove_dir},
522 {"touch", file_utime}, 541 {"touch", file_utime},
523 {"unlock", file_unlock}, 542 {"unlock", file_unlock},
524 {NULL, NULL}, 543 {NULL, NULL},