diff options
| author | tomas <tomas> | 2005-01-19 14:28:58 +0000 |
|---|---|---|
| committer | tomas <tomas> | 2005-01-19 14:28:58 +0000 |
| commit | 508c7b3b569c7370f4ec54eebb88ceee0354f428 (patch) | |
| tree | 87e188fc4a899a3e4f026828c76dba9ef271ea05 /src | |
| parent | e99b7844bbb893d3d414e8e711b3706b8cf2b8a4 (diff) | |
| download | luafilesystem-508c7b3b569c7370f4ec54eebb88ceee0354f428.tar.gz luafilesystem-508c7b3b569c7370f4ec54eebb88ceee0354f428.tar.bz2 luafilesystem-508c7b3b569c7370f4ec54eebb88ceee0354f428.zip | |
Eliminando funcao lfs.touch() para lancamento da versao 1.0 oficial.
Diffstat (limited to 'src')
| -rw-r--r-- | src/lfs.c | 36 |
1 files changed, 4 insertions, 32 deletions
| @@ -7,10 +7,9 @@ | |||
| 7 | ** lfs.dir (path) | 7 | ** lfs.dir (path) |
| 8 | ** lfs.mkdir (path) | 8 | ** lfs.mkdir (path) |
| 9 | ** lfs.lock (fh, mode) | 9 | ** lfs.lock (fh, mode) |
| 10 | ** lfs.touch (filepath [, atime [, mtime]]) | ||
| 11 | ** lfs.unlock (fh) | 10 | ** lfs.unlock (fh) |
| 12 | ** | 11 | ** |
| 13 | ** $Id: lfs.c,v 1.16 2005/01/18 11:21:58 tuler Exp $ | 12 | ** $Id: lfs.c,v 1.17 2005/01/19 14:28:58 tomas Exp $ |
| 14 | */ | 13 | */ |
| 15 | 14 | ||
| 16 | #include <errno.h> | 15 | #include <errno.h> |
| @@ -23,13 +22,11 @@ | |||
| 23 | #include <direct.h> | 22 | #include <direct.h> |
| 24 | #include <io.h> | 23 | #include <io.h> |
| 25 | #include <sys/locking.h> | 24 | #include <sys/locking.h> |
| 26 | #include <sys/utime.h> | ||
| 27 | #else | 25 | #else |
| 28 | #include <unistd.h> | 26 | #include <unistd.h> |
| 29 | #include <dirent.h> | 27 | #include <dirent.h> |
| 30 | #include <fcntl.h> | 28 | #include <fcntl.h> |
| 31 | #include <sys/types.h> | 29 | #include <sys/types.h> |
| 32 | #include <utime.h> | ||
| 33 | #endif | 30 | #endif |
| 34 | 31 | ||
| 35 | #include "lua.h" | 32 | #include "lua.h" |
| @@ -148,7 +145,7 @@ static int _file_lock (lua_State *L, FILE *fh, const char *mode, const long star | |||
| 148 | case 'w': f.l_type = F_WRLCK; break; | 145 | case 'w': f.l_type = F_WRLCK; break; |
| 149 | case 'r': f.l_type = F_RDLCK; break; | 146 | case 'r': f.l_type = F_RDLCK; break; |
| 150 | case 'u': f.l_type = F_UNLCK; break; | 147 | case 'u': f.l_type = F_UNLCK; break; |
| 151 | default : luaL_error (L, "%s: invalid mode", funcname); | 148 | default : return luaL_error (L, "%s: invalid mode", funcname); |
| 152 | } | 149 | } |
| 153 | f.l_whence = SEEK_SET; | 150 | f.l_whence = SEEK_SET; |
| 154 | f.l_start = (off_t)start; | 151 | f.l_start = (off_t)start; |
| @@ -398,30 +395,6 @@ static const char *mode2string (mode_t mode) { | |||
| 398 | 395 | ||
| 399 | 396 | ||
| 400 | /* | 397 | /* |
| 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 | /* | ||
| 425 | ** Get file information | 398 | ** Get file information |
| 426 | */ | 399 | */ |
| 427 | static int file_info (lua_State *L) { | 400 | static int file_info (lua_State *L) { |
| @@ -498,7 +471,7 @@ static int file_info (lua_State *L) { | |||
| 498 | */ | 471 | */ |
| 499 | static void set_info (lua_State *L) { | 472 | static void set_info (lua_State *L) { |
| 500 | lua_pushliteral (L, "_COPYRIGHT"); | 473 | lua_pushliteral (L, "_COPYRIGHT"); |
| 501 | lua_pushliteral (L, "Copyright (C) 2004 Kepler Project"); | 474 | lua_pushliteral (L, "Copyright (C) 2004-2005 Kepler Project"); |
| 502 | lua_settable (L, -3); | 475 | lua_settable (L, -3); |
| 503 | lua_pushliteral (L, "_DESCRIPTION"); | 476 | lua_pushliteral (L, "_DESCRIPTION"); |
| 504 | lua_pushliteral (L, "LuaFileSystem is a Lua library developed to complement the set of functions related to file systems offered by the standard Lua distribution"); | 477 | lua_pushliteral (L, "LuaFileSystem is a Lua library developed to complement the set of functions related to file systems offered by the standard Lua distribution"); |
| @@ -507,7 +480,7 @@ static void set_info (lua_State *L) { | |||
| 507 | lua_pushliteral (L, "LuaFileSystem"); | 480 | lua_pushliteral (L, "LuaFileSystem"); |
| 508 | lua_settable (L, -3); | 481 | lua_settable (L, -3); |
| 509 | lua_pushliteral (L, "_VERSION"); | 482 | lua_pushliteral (L, "_VERSION"); |
| 510 | lua_pushliteral (L, "1.0b"); | 483 | lua_pushliteral (L, "1.0"); |
| 511 | lua_settable (L, -3); | 484 | lua_settable (L, -3); |
| 512 | } | 485 | } |
| 513 | 486 | ||
| @@ -519,7 +492,6 @@ static const struct luaL_reg fslib[] = { | |||
| 519 | {"dir", dir_iter_factory}, | 492 | {"dir", dir_iter_factory}, |
| 520 | {"lock", file_lock}, | 493 | {"lock", file_lock}, |
| 521 | {"mkdir", make_dir}, | 494 | {"mkdir", make_dir}, |
| 522 | {"touch", file_utime}, | ||
| 523 | {"unlock", file_unlock}, | 495 | {"unlock", file_unlock}, |
| 524 | {NULL, NULL}, | 496 | {NULL, NULL}, |
| 525 | }; | 497 | }; |
