summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Ryde <user42@zip.com.au>2003-09-12 23:35:54 +0000
committerKevin Ryde <user42@zip.com.au>2003-09-12 23:35:54 +0000
commit833fc2f186a52c9b4180fcd215e7faae626bbb80 (patch)
treea5b7d9e76a45530782bdbd1c9cb12bc4967c2190
parent97a61c5f91dc2524bac085a373890543a3fb21f5 (diff)
downloadguile-833fc2f186a52c9b4180fcd215e7faae626bbb80.tar.gz
(file-exists?): Use stat rather than access?, so as to
follow the effective UID/GID not the real ID. file-exists? is normally be used as a prelude to opening or some other operation, and it's the effective ID which will apply there. Emacs file-exists-p uses stat, presumably for the the same reason.
-rw-r--r--ice-9/boot-9.scm4
1 files changed, 3 insertions, 1 deletions
diff --git a/ice-9/boot-9.scm b/ice-9/boot-9.scm
index e3620e038..5ec9b3234 100644
--- a/ice-9/boot-9.scm
+++ b/ice-9/boot-9.scm
@@ -407,10 +407,12 @@
(if (provided? 'socket)
(primitive-load-path "ice-9/networking.scm"))
+;; ENHANCE-ME: Catching an exception from stat is a bit wasteful, do this in
+;; C where all that's needed is to inspect the return from stat().
(define file-exists?
(if (provided? 'posix)
(lambda (str)
- (access? str F_OK))
+ (->bool (false-if-exception (stat str))))
(lambda (str)
(let ((port (catch 'system-error (lambda () (open-file str OPEN_READ))
(lambda args #f))))