aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile4
-rw-r--r--src/lfs.c34
-rw-r--r--vc6/lfs.def2
3 files changed, 34 insertions, 6 deletions
diff --git a/Makefile b/Makefile
index 5a75e04..b0bf741 100644
--- a/Makefile
+++ b/Makefile
@@ -1,10 +1,10 @@
1# $Id: Makefile,v 1.12 2005/01/19 14:28:58 tomas Exp $ 1# $Id: Makefile,v 1.13 2005/01/21 10:19:04 tomas Exp $
2 2
3T= lfs 3T= lfs
4 4
5include ./config 5include ./config
6 6
7V= 1.0 7V= 1.1b
8DIST_DIR= luafilesystem-$V 8DIST_DIR= luafilesystem-$V
9TAR_FILE= $(DIST_DIR).tar.gz 9TAR_FILE= $(DIST_DIR).tar.gz
10ZIP_FILE= $(DIST_DIR).zip 10ZIP_FILE= $(DIST_DIR).zip
diff --git a/src/lfs.c b/src/lfs.c
index 4b4db61..5e09823 100644
--- a/src/lfs.c
+++ b/src/lfs.c
@@ -5,11 +5,12 @@
5** lfs.chdir (path) 5** lfs.chdir (path)
6** lfs.currentdir () 6** lfs.currentdir ()
7** lfs.dir (path) 7** lfs.dir (path)
8** lfs.mkdir (path)
9** lfs.lock (fh, mode) 8** lfs.lock (fh, mode)
9** lfs.mkdir (path)
10** lfs.touch (filepath [, atime [, mtime]])
10** lfs.unlock (fh) 11** lfs.unlock (fh)
11** 12**
12** $Id: lfs.c,v 1.17 2005/01/19 14:28:58 tomas Exp $ 13** $Id: lfs.c,v 1.18 2005/01/21 10:19:04 tomas Exp $
13*/ 14*/
14 15
15#include <errno.h> 16#include <errno.h>
@@ -22,11 +23,13 @@
22#include <direct.h> 23#include <direct.h>
23#include <io.h> 24#include <io.h>
24#include <sys/locking.h> 25#include <sys/locking.h>
26#include <sys/utime.h>
25#else 27#else
26#include <unistd.h> 28#include <unistd.h>
27#include <dirent.h> 29#include <dirent.h>
28#include <fcntl.h> 30#include <fcntl.h>
29#include <sys/types.h> 31#include <sys/types.h>
32#include <utime.h>
30#endif 33#endif
31 34
32#include "lua.h" 35#include "lua.h"
@@ -395,6 +398,30 @@ static const char *mode2string (mode_t mode) {
395 398
396 399
397/* 400/*
401** Set access time and modification values for file
402*/
403static int file_utime (lua_State *L) {
404 const char *file = luaL_checkstring (L, 1);
405 struct utimbuf utb, *buf;
406
407 if (lua_gettop (L) == 1) /* set to current date/time */
408 buf = NULL;
409 else {
410 utb.actime = (time_t)luaL_optnumber (L, 2, 0);
411 utb.modtime = (time_t)luaL_optnumber (L, 3, utb.actime);
412 buf = &utb;
413 }
414 if (utime (file, buf)) {
415 lua_pushnil (L);
416 lua_pushfstring (L, "%s", strerror (errno));
417 return 2;
418 }
419 lua_pushboolean (L, 1);
420 return 1;
421}
422
423
424/*
398** Get file information 425** Get file information
399*/ 426*/
400static int file_info (lua_State *L) { 427static int file_info (lua_State *L) {
@@ -480,7 +507,7 @@ static void set_info (lua_State *L) {
480 lua_pushliteral (L, "LuaFileSystem"); 507 lua_pushliteral (L, "LuaFileSystem");
481 lua_settable (L, -3); 508 lua_settable (L, -3);
482 lua_pushliteral (L, "_VERSION"); 509 lua_pushliteral (L, "_VERSION");
483 lua_pushliteral (L, "1.0"); 510 lua_pushliteral (L, "1.1b");
484 lua_settable (L, -3); 511 lua_settable (L, -3);
485} 512}
486 513
@@ -492,6 +519,7 @@ static const struct luaL_reg fslib[] = {
492 {"dir", dir_iter_factory}, 519 {"dir", dir_iter_factory},
493 {"lock", file_lock}, 520 {"lock", file_lock},
494 {"mkdir", make_dir}, 521 {"mkdir", make_dir},
522 {"touch", file_utime},
495 {"unlock", file_unlock}, 523 {"unlock", file_unlock},
496 {NULL, NULL}, 524 {NULL, NULL},
497}; 525};
diff --git a/vc6/lfs.def b/vc6/lfs.def
index b2d5650..29d8a1f 100644
--- a/vc6/lfs.def
+++ b/vc6/lfs.def
@@ -1,5 +1,5 @@
1LIBRARY lfs.dll 1LIBRARY lfs.dll
2DESCRIPTION "LuaFileSystem" 2DESCRIPTION "LuaFileSystem"
3VERSION 1.0 3VERSION 1.1
4EXPORTS 4EXPORTS
5luaopen_lfs 5luaopen_lfs