Ignore:
Timestamp:
01/30/14 14:10:03 (8 years ago)
Author:
Mark Evenson
Message:

CL:DIRECTORY semantics for symbolic link resolution inverted and fixed.

The default for the :RESOLVE-SYMLINKS keyword to CL:DIRECTORY has
changed from T to nil, meaning that naked DIRECTORY calls should never
return an error for dangling symlinks.

Thanks to Marco Antoniotti, Alan Ruttenberg, and Alessio Stallo for
clarifying a reasonable position vis a vis ANSI.

Addresses <http://abcl.org/trac/ticket/340>.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/abcl/src/org/armedbear/lisp/directory.lisp

    r14176 r14619  
    9797                   entries))))))
    9898
     99;;; XXX Kludge for compatibilty:  hope no one uses.
     100(defun directory-old (pathspec &key (resolve-symlinks t))
     101  (warn "Deprecated:  Please use CL:DIRECTORY which has a NIL default for :RESOLVE-SYMLINKS.")
     102  (directory pathspec :resolve-symlinks resolve-symlinks))
    99103
    100 (defun directory (pathspec &key (resolve-symlinks t))
     104(defun directory (pathspec &key (resolve-symlinks nil))
     105  "Determines which, if any, files that are present in the file system have names matching PATHSPEC, and returns
     106a fresh list of pathnames corresponding to the potential truenames of those files. 
     107
     108With :RESOLVE-SYMLINKS set to nil, not all pathnames returned may
     109correspond to an existing file.  Symbolic links are considered to be
     110be valid entries even if they do not currently have a valid file or
     111directory as a target.  Therefore, subsequent CL:TRUENAME call on
     112individual pathnames in the list may signal an error, i.e. the
     113pathnames have been constructed as truenames, without calling the
     114entire resolution routine of CL:TRUENAME.
     115
     116If called with :RESOLVE-SYMLINKS set to T, and any of the pathnames
     117have truenames which do not exist, this routine will signal a file
     118error to its caller."
     119
    101120  (let ((pathname (merge-pathnames pathspec)))
    102121    (when (logical-pathname-p pathname)
     
    116135                      (matching-entries ()))
    117136                  (dolist (entry entries)
    118                     (cond ((file-directory-p entry)
    119                            (when (pathname-match-p (file-namestring (pathname-as-file entry)) (file-namestring pathname))
    120                              (push (truename entry) matching-entries)))
    121                           ((pathname-match-p (or (file-namestring entry) "") (file-namestring pathname))
    122                            (push (truename entry) matching-entries))))
     137          (when
     138            (or
     139             (and
     140              (file-directory-p entry)
     141              (pathname-match-p (file-namestring (pathname-as-file entry))
     142                      (file-namestring pathname)))
     143             (pathname-match-p (or (file-namestring entry) "") (file-namestring pathname)))
     144            (push
     145             (if resolve-symlinks
     146               (truename entry)
     147               entry)
     148             matching-entries)))
    123149                  matching-entries))))
    124150        ;; Not wild.
Note: See TracChangeset for help on using the changeset viewer.