Return errno from lfs.touch on error

This commit is contained in:
Peter Melnichenko
2016-05-04 15:17:21 +03:00
parent 8b85d257a6
commit 8f167ef1de

View File

@@ -646,7 +646,10 @@ static const char *mode2string (mode_t mode) {
/* /*
** Set access time and modification values for file ** Set access time and modification values for a file.
** @param #1 File path.
** @param #2 Access time in seconds, current time is used if missing.
** @param #3 Modification time in seconds, access time is used if missing.
*/ */
static int file_utime (lua_State *L) { static int file_utime (lua_State *L) {
const char *file = luaL_checkstring(L, 1); const char *file = luaL_checkstring(L, 1);
@@ -659,13 +662,8 @@ static int file_utime (lua_State *L) {
utb.modtime = (time_t) luaL_optinteger(L, 3, utb.actime); utb.modtime = (time_t) luaL_optinteger(L, 3, utb.actime);
buf = &utb; buf = &utb;
} }
if (utime (file, buf)) {
lua_pushnil (L); return pushresult(L, utime(file, buf), NULL);
lua_pushfstring (L, "%s", strerror (errno));
return 2;
}
lua_pushboolean (L, 1);
return 1;
} }