Traversing (walking) directories
See uiop:collect-sub*directories in uiop/filesystem. It takes as arguments:
- a
directory - a
recursepfunction - a
collectpfunction - a
collectorfunction
Given a directory, when collectp returns true with the directory, call the collector function on the directory, and recurse each of its subdirectories on which recursep returns true.
This function will thus let you traverse a filesystem hierarchy, superseding the functionality of cl-fad:walk-directory.
The behavior in presence of symlinks is not portable. Use IOlib to handle such situations.
Example:
(defparameter *dirs* nil "All recursive directories.")
(uiop:collect-sub*directories "~/cl-cookbook"
(constantly t)
(constantly t)
(lambda (it) (push it *dirs*)))
Also, cl-fad:walk-directory can be used if you want to collect not only subdirectories, but also the files:
(cl-fad:walk-directory "./"
(lambda (name)
(format t "~A~%" name))
By the way, in your example, you can use (constantly t) instead of (lambda (it) t).
perfect, thanks.