diff options
| author | tomas <tomas> | 2004-11-01 15:27:13 +0000 |
|---|---|---|
| committer | tomas <tomas> | 2004-11-01 15:27:13 +0000 |
| commit | 4d5d1e75fa5950b39873b46b3ab21fd39028e4f1 (patch) | |
| tree | e2597be505a2ddaa87479c4549f8a51bf93a6ff1 /src | |
| parent | 3219f4618df9fa4f4a54d2d3bcc116380bafa217 (diff) | |
| download | luafilesystem-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')
| -rw-r--r-- | src/lfs.c | 15 |
1 files changed, 11 insertions, 4 deletions
| @@ -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 | */ |
| 65 | static int change_dir (lua_State *L) { | 65 | static 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 | } |
