diff options
-rw-r--r-- | src/lfs.c | 12 | ||||
-rw-r--r-- | tests/test.lua | 2 |
2 files changed, 8 insertions, 6 deletions
@@ -14,7 +14,7 @@ | |||
14 | ** lfs.touch (filepath [, atime [, mtime]]) | 14 | ** lfs.touch (filepath [, atime [, mtime]]) |
15 | ** lfs.unlock (fh) | 15 | ** lfs.unlock (fh) |
16 | ** | 16 | ** |
17 | ** $Id: lfs.c,v 1.31 2006/03/13 00:06:24 tomas Exp $ | 17 | ** $Id: lfs.c,v 1.32 2006/03/14 13:39:38 tomas Exp $ |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include <errno.h> | 20 | #include <errno.h> |
@@ -182,7 +182,7 @@ static int file_lock (lua_State *L) { | |||
182 | lua_pushboolean (L, 1); | 182 | lua_pushboolean (L, 1); |
183 | return 1; | 183 | return 1; |
184 | } else { | 184 | } else { |
185 | lua_pushboolean (L, 0); | 185 | lua_pushnil (L); |
186 | lua_pushfstring (L, "%s", strerror(errno)); | 186 | lua_pushfstring (L, "%s", strerror(errno)); |
187 | return 2; | 187 | return 2; |
188 | } | 188 | } |
@@ -203,7 +203,7 @@ static int file_unlock (lua_State *L) { | |||
203 | lua_pushboolean (L, 1); | 203 | lua_pushboolean (L, 1); |
204 | return 1; | 204 | return 1; |
205 | } else { | 205 | } else { |
206 | lua_pushboolean (L, 0); | 206 | lua_pushnil (L); |
207 | lua_pushfstring (L, "%s", strerror(errno)); | 207 | lua_pushfstring (L, "%s", strerror(errno)); |
208 | return 2; | 208 | return 2; |
209 | } | 209 | } |
@@ -221,12 +221,13 @@ static int make_dir (lua_State *L) { | |||
221 | fail = mkdir (path, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | | 221 | fail = mkdir (path, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | |
222 | S_IWGRP | S_IXGRP | S_IROTH | S_IXOTH ); | 222 | S_IWGRP | S_IXGRP | S_IROTH | S_IXOTH ); |
223 | #endif | 223 | #endif |
224 | lua_pushboolean (L, !fail); | ||
225 | if (fail) { | 224 | if (fail) { |
225 | lua_pushnil (L); | ||
226 | lua_pushfstring (L, "%s", strerror(errno)); | 226 | lua_pushfstring (L, "%s", strerror(errno)); |
227 | return 2; | 227 | return 2; |
228 | } | 228 | } |
229 | umask (oldmask); | 229 | umask (oldmask); |
230 | lua_pushboolean (L, 1); | ||
230 | return 1; | 231 | return 1; |
231 | } | 232 | } |
232 | 233 | ||
@@ -240,11 +241,12 @@ static int remove_dir (lua_State *L) { | |||
240 | 241 | ||
241 | fail = rmdir (path); | 242 | fail = rmdir (path); |
242 | 243 | ||
243 | lua_pushboolean (L, !fail); | ||
244 | if (fail) { | 244 | if (fail) { |
245 | lua_pushnil (L); | ||
245 | lua_pushfstring (L, "%s", strerror(errno)); | 246 | lua_pushfstring (L, "%s", strerror(errno)); |
246 | return 2; | 247 | return 2; |
247 | } | 248 | } |
249 | lua_pushboolean (L, 1); | ||
248 | return 1; | 250 | return 1; |
249 | } | 251 | } |
250 | 252 | ||
diff --git a/tests/test.lua b/tests/test.lua index 1f4eb09..8da5d16 100644 --- a/tests/test.lua +++ b/tests/test.lua | |||
@@ -64,7 +64,7 @@ assert (new_att.modification == attrib.modification) | |||
64 | -- Remove new file and directory | 64 | -- Remove new file and directory |
65 | assert (os.remove (tmpfile), "could not remove new file") | 65 | assert (os.remove (tmpfile), "could not remove new file") |
66 | assert (lfs.rmdir (tmpdir), "could not remove new directory") | 66 | assert (lfs.rmdir (tmpdir), "could not remove new directory") |
67 | assert (lfs.mkdir (tmpdir..sep.."lfs_tmp_dir") == false, "could create a directory inside a non-existent one") | 67 | assert (lfs.mkdir (tmpdir..sep.."lfs_tmp_dir") == nil, "could create a directory inside a non-existent one") |
68 | 68 | ||
69 | -- Trying to get attributes of a non-existent file | 69 | -- Trying to get attributes of a non-existent file |
70 | assert (lfs.attributes ("this couldn't be an actual file") == nil, "could get attributes of a non-existent file") | 70 | assert (lfs.attributes ("this couldn't be an actual file") == nil, "could get attributes of a non-existent file") |