From 4d5d1e75fa5950b39873b46b3ab21fd39028e4f1 Mon Sep 17 00:00:00 2001 From: tomas Date: Mon, 1 Nov 2004 15:27:13 +0000 Subject: Pequenas correcoes nos valores de retorno de algumas funcoes. Acrescimo do arquivo de testes. --- src/lfs.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/lfs.c b/src/lfs.c index e1dfb74..01f4076 100644 --- a/src/lfs.c +++ b/src/lfs.c @@ -9,7 +9,7 @@ ** lfs.lock (fh, mode) ** lfs.unlock (fh) ** -** $Id: lfs.c,v 1.7 2004/11/01 08:57:56 tomas Exp $ +** $Id: lfs.c,v 1.8 2004/11/01 15:27:13 tomas Exp $ */ #include @@ -64,10 +64,15 @@ typedef struct dir_data { */ static int change_dir (lua_State *L) { const char *path = luaL_checkstring(L, 1); - if (chdir(path)) - luaL_error(L,"Unable to change working directory to '%s'\n%s\n", + if (chdir(path)) { + lua_pushnil (L); + lua_pushfstring (L,"Unable to change working directory to '%s'\n%s\n", path, chdir_error); - return 0; + return 2; + } else { + lua_pushboolean (L, 1); + return 1; + } } /* @@ -234,6 +239,8 @@ static int make_dir (lua_State *L) { S_IWGRP | S_IXGRP | S_IROTH | S_IXOTH ); #endif lua_pushboolean (L, !fail); + if (fail) + lua_pushfstring (L, "%s", strerror(errno)); umask (oldmask); return 1; } -- cgit v1.2.3-55-g6feb