aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortomas <tomas>2006-03-14 13:39:38 +0000
committertomas <tomas>2006-03-14 13:39:38 +0000
commit121ae680f1c897d8773041781a6a7bd0c85010fc (patch)
tree155816b0d245e22e8ba8515fdf19936b1267158d /src
parent1a1716f876e2451e73c953aba1e30e97dab189dd (diff)
downloadluafilesystem-121ae680f1c897d8773041781a6a7bd0c85010fc.tar.gz
luafilesystem-121ae680f1c897d8773041781a6a7bd0c85010fc.tar.bz2
luafilesystem-121ae680f1c897d8773041781a6a7bd0c85010fc.zip
Standardizing execution errors to nil followed by an error message
Diffstat (limited to 'src')
-rw-r--r--src/lfs.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/lfs.c b/src/lfs.c
index 18fff62..7c8f62a 100644
--- a/src/lfs.c
+++ b/src/lfs.c
@@ -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