mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-22 19:44:10 +02:00
(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.
This commit is contained in:
parent
97a61c5f91
commit
833fc2f186
1 changed files with 3 additions and 1 deletions
|
@ -407,10 +407,12 @@
|
||||||
(if (provided? 'socket)
|
(if (provided? 'socket)
|
||||||
(primitive-load-path "ice-9/networking.scm"))
|
(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?
|
(define file-exists?
|
||||||
(if (provided? 'posix)
|
(if (provided? 'posix)
|
||||||
(lambda (str)
|
(lambda (str)
|
||||||
(access? str F_OK))
|
(->bool (false-if-exception (stat str))))
|
||||||
(lambda (str)
|
(lambda (str)
|
||||||
(let ((port (catch 'system-error (lambda () (open-file str OPEN_READ))
|
(let ((port (catch 'system-error (lambda () (open-file str OPEN_READ))
|
||||||
(lambda args #f))))
|
(lambda args #f))))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue