diff options
-rw-r--r-- | Makefile | 4 | ||||
-rw-r--r-- | src/lfs.c | 34 | ||||
-rw-r--r-- | vc6/lfs.def | 2 |
3 files changed, 34 insertions, 6 deletions
@@ -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 | ||
3 | T= lfs | 3 | T= lfs |
4 | 4 | ||
5 | include ./config | 5 | include ./config |
6 | 6 | ||
7 | V= 1.0 | 7 | V= 1.1b |
8 | DIST_DIR= luafilesystem-$V | 8 | DIST_DIR= luafilesystem-$V |
9 | TAR_FILE= $(DIST_DIR).tar.gz | 9 | TAR_FILE= $(DIST_DIR).tar.gz |
10 | ZIP_FILE= $(DIST_DIR).zip | 10 | ZIP_FILE= $(DIST_DIR).zip |
@@ -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 | */ | ||
403 | static 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 | */ |
400 | static int file_info (lua_State *L) { | 427 | static 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 @@ | |||
1 | LIBRARY lfs.dll | 1 | LIBRARY lfs.dll |
2 | DESCRIPTION "LuaFileSystem" | 2 | DESCRIPTION "LuaFileSystem" |
3 | VERSION 1.0 | 3 | VERSION 1.1 |
4 | EXPORTS | 4 | EXPORTS |
5 | luaopen_lfs | 5 | luaopen_lfs |