aboutsummaryrefslogtreecommitdiff
path: root/src/lfs.c
diff options
context:
space:
mode:
authortomas <tomas>2004-11-01 15:27:13 +0000
committertomas <tomas>2004-11-01 15:27:13 +0000
commit4d5d1e75fa5950b39873b46b3ab21fd39028e4f1 (patch)
treee2597be505a2ddaa87479c4549f8a51bf93a6ff1 /src/lfs.c
parent3219f4618df9fa4f4a54d2d3bcc116380bafa217 (diff)
downloadluafilesystem-4d5d1e75fa5950b39873b46b3ab21fd39028e4f1.tar.gz
luafilesystem-4d5d1e75fa5950b39873b46b3ab21fd39028e4f1.tar.bz2
luafilesystem-4d5d1e75fa5950b39873b46b3ab21fd39028e4f1.zip
Pequenas correcoes nos valores de retorno de algumas funcoes.
Acrescimo do arquivo de testes.
Diffstat (limited to 'src/lfs.c')
-rw-r--r--src/lfs.c15
1 files changed, 11 insertions, 4 deletions
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 @@
9** lfs.lock (fh, mode) 9** lfs.lock (fh, mode)
10** lfs.unlock (fh) 10** lfs.unlock (fh)
11** 11**
12** $Id: lfs.c,v 1.7 2004/11/01 08:57:56 tomas Exp $ 12** $Id: lfs.c,v 1.8 2004/11/01 15:27:13 tomas Exp $
13*/ 13*/
14 14
15#include <errno.h> 15#include <errno.h>
@@ -64,10 +64,15 @@ typedef struct dir_data {
64*/ 64*/
65static int change_dir (lua_State *L) { 65static int change_dir (lua_State *L) {
66 const char *path = luaL_checkstring(L, 1); 66 const char *path = luaL_checkstring(L, 1);
67 if (chdir(path)) 67 if (chdir(path)) {
68 luaL_error(L,"Unable to change working directory to '%s'\n%s\n", 68 lua_pushnil (L);
69 lua_pushfstring (L,"Unable to change working directory to '%s'\n%s\n",
69 path, chdir_error); 70 path, chdir_error);
70 return 0; 71 return 2;
72 } else {
73 lua_pushboolean (L, 1);
74 return 1;
75 }
71} 76}
72 77
73/* 78/*
@@ -234,6 +239,8 @@ static int make_dir (lua_State *L) {
234 S_IWGRP | S_IXGRP | S_IROTH | S_IXOTH ); 239 S_IWGRP | S_IXGRP | S_IROTH | S_IXOTH );
235#endif 240#endif
236 lua_pushboolean (L, !fail); 241 lua_pushboolean (L, !fail);
242 if (fail)
243 lua_pushfstring (L, "%s", strerror(errno));
237 umask (oldmask); 244 umask (oldmask);
238 return 1; 245 return 1;
239} 246}