chicken-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-hackers] [PATCH] handle EOVERFLOW and ENOTDIR gracefully in fil


From: Felix
Subject: [Chicken-hackers] [PATCH] handle EOVERFLOW and ENOTDIR gracefully in file/directory-exists?
Date: Sat, 08 Oct 2011 15:11:29 +0200 (CEST)

This patches avoids an error when "[file|directory]-exists?"  gets
EOVERFLOW or ENOTDIR, which indicate an existing or no-existing file,
respectively.


cheers,
felix


commit 473edf9428a7bc38fc033e86d0bbcb362f1cd2d8
Author: felix <address@hidden>
Date:   Sat Oct 8 15:09:42 2011 +0200

    handle EOVERFLOW and ENOTDIR gracefully in file/directory-exists?

diff --git a/runtime.c b/runtime.c
index a6d7919..f9f8459 100644
--- a/runtime.c
+++ b/runtime.c
@@ -9246,8 +9246,12 @@ C_i_file_exists_p(C_word name, C_word file, C_word dir)
   res = stat(C_c_string(name), &buf);
 
   if(res != 0) {
-    if(errno == ENOENT) return C_SCHEME_FALSE;
-    else return C_fix(res);
+    switch(errno) {
+    case ENOENT: return C_SCHEME_FALSE;
+    case EOVERFLOW: return C_truep(dir) ? C_SCHEME_FALSE : C_SCHEME_TRUE;
+    case ENOTDIR: return C_SCHEME_FALSE;
+    default: return C_fix(res);
+    }
   }
 
   switch(buf.st_mode & S_IFMT) {

reply via email to

[Prev in Thread] Current Thread [Next in Thread]