uiop:directory-files doesn't behave on paths without a trailing slash

Robert Goldman rpgoldman at sift.info
Mon Jun 24 20:36:21 UTC 2019


Thanks for this patch.  I have pushed it (it can be seen in master as 
version 3.3.4), together with a simple test.

On 24 Jun 2019, at 12:22, Neil Lindquist wrote:

> Hello,
>
> I recently noticed that uiop's DIRECTORY-FILES does not ensure that
> the path is always interpreted as a directory.  On sbcl (and
> presumably other implementations), if the path does not have a
> trailing slash, the files in the parent directory are instead
> returned.  This does not appear to be the indented behavior, given
> that SUBDIRECTORIES ensures that the path is a directory.  A patch for
> this new behavior and current/proposed results are below.
>
> Neil Lindquist
>
>
> ## Patch ##
> --- a/uiop/filesystem.lisp
> +++ b/uiop/filesystem.lisp
> @@ -209,7 +209,7 @@ Subdirectories should NOT be returned.
>  override the default at your own risk.
>    DIRECTORY-FILES tries NOT to resolve symlinks if the implementation
> permits this,
>  but the behavior in presence of symlinks is not portable. Use IOlib
> to handle such situations."
> -    (let ((dir (pathname directory)))
> +    (let ((dir (ensure-directory-pathname directory))))
>        (when (logical-pathname-p dir)
>          ;; Because of the filtering we do below,
>          ;; logical pathnames have restrictions on wild patterns.
>
>
> ## Current behavior ##
> CL-USER> (uiop:directory-files "doc")
> (#P"C:/Users/Neil/Documents/coding/lisp/asdf/uiop/README.md"
>  #P"C:/Users/Neil/Documents/coding/lisp/asdf/uiop/asdf-driver.asd"
>  #P"C:/Users/Neil/Documents/coding/lisp/asdf/uiop/backward-driver.lisp"
>  #P"C:/Users/Neil/Documents/coding/lisp/asdf/uiop/common-lisp.lisp"
>  #P"C:/Users/Neil/Documents/coding/lisp/asdf/uiop/configuration.lisp"
>  #P"C:/Users/Neil/Documents/coding/lisp/asdf/uiop/driver.lisp"
>  #P"C:/Users/Neil/Documents/coding/lisp/asdf/uiop/filesystem.lisp"
>  #P"C:/Users/Neil/Documents/coding/lisp/asdf/uiop/image.lisp"
>  #P"C:/Users/Neil/Documents/coding/lisp/asdf/uiop/launch-program.lisp"
>  #P"C:/Users/Neil/Documents/coding/lisp/asdf/uiop/lisp-build.lisp"
>  #P"C:/Users/Neil/Documents/coding/lisp/asdf/uiop/os.lisp"
>  #P"C:/Users/Neil/Documents/coding/lisp/asdf/uiop/package.lisp"
>  #P"C:/Users/Neil/Documents/coding/lisp/asdf/uiop/pathname.lisp"
>  #P"C:/Users/Neil/Documents/coding/lisp/asdf/uiop/run-program.lisp"
>  #P"C:/Users/Neil/Documents/coding/lisp/asdf/uiop/stream.lisp"
>  #P"C:/Users/Neil/Documents/coding/lisp/asdf/uiop/uiop.asd"
>  #P"C:/Users/Neil/Documents/coding/lisp/asdf/uiop/utility.lisp"
>  #P"C:/Users/Neil/Documents/coding/lisp/asdf/uiop/version.lisp")
>
>
> ## Proposed Behavior ##
> COMMON-LISP-USER> (uiop:directory-files "doc")
> (#P"C:/Users/Neil/Documents/coding/lisp/asdf/uiop/doc/.gitignore"
>  #P"C:/Users/Neil/Documents/coding/lisp/asdf/uiop/doc/Makefile"
>  #P"C:/Users/Neil/Documents/coding/lisp/asdf/uiop/doc/docstrings.lisp"
>  #P"C:/Users/Neil/Documents/coding/lisp/asdf/uiop/doc/template.texinfo")



More information about the asdf-devel mailing list