[gambit-list] checking for dangling symlink without raising an exception

Thomas Hafner thomas at hafner.NL.EU.ORG
Wed Jan 11 14:16:17 EST 2006


Is it possible to check for a symlink without raising an exception,
even if the symling is dangling?

I think not, because:
- file-exists? cannot be used to check, because it evaluates to #f in
  case of a dangling symlink.
- file-info cannot be used to check, because it raises an exception,
  if there's nothing.

Here's an example:

(create-symbolic-link "/doesnotexist" "~/dangling")
;; worked, the symlink has been created.

(file-exists? "~/dangling")
;; evaluates to #f.

(create-symbolic-link "/anotherplace" "~/dangling")
;; ERROR: File exists.

(file-info "~/dangling")
;; ERROR: No such file or directory.

(file-info "~/dangling" #f)
;; Ok, informs about the symlink.

(delete-file "~/dangling")
(file-info "~/dangling" #f)
;; ERROR: No such file or directory.

I think it would be nice, if file-exists? had also an optional
parameter ``CHASE?'' like file-info has.

Regards
  Thomas



More information about the Gambit-list mailing list