Commit f0564371fd0ff7de211fbc803a1140e053bd3334

Thomas de Grivel 2018-06-15T19:35:55

use access instead of open

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
diff --git a/thot.lisp b/thot.lisp
index bebb42c..2978bd4 100644
--- a/thot.lisp
+++ b/thot.lisp
@@ -389,12 +389,9 @@ The requested url "
       t)))
 
 (defun probe-file (path)
-  (when (with-stat (stat) path
-                   (s-isreg (the fixnum (stat-mode stat))))
-    (let ((filep (the fixnum (fcntl:c-open/2 path fcntl:+o-rdonly+))))
-      (unless (< filep 0)
-        (unistd:close filep)
-        t))))
+  (when (with-stat (stat nil) path
+          (s-isreg (the fixnum (stat-mode stat))))
+    (= 0 (the fixnum (unistd:c-access path unistd:+r-ok+)))))
 
 (defun prefix-p (pre str)
   (declare (type simple-string pre str))