stylewarning / quickutil

The solution to the Utility Library problem.
87 stars 8 forks source link

WALK-DIRECTORY-TREE #66

Open j3pic opened 3 years ago

j3pic commented 3 years ago

;; Write the code here.

(defun walk-directory-tree (file-handler pathname)
    "Walks down a directory tree and calls the FILE-HANDLER on every                                                                                                               
non-directory file.                                                                                                                                                                

You can invoke the restart SKIP-FILE to skip processing of the current file, or                                                                                                    
RETRY to call your FILE-HANDLER again with the same file."
    (map-directory (lambda (file)
                     (if (uiop/filesystem:directory-exists-p file)
                         (walk-directory-tree file-handler file)
                         (with-retry retry "Try processing this file again"
                           (restart-case (funcall file-handler file)
                             (skip-file () :report "Skip this file"
                                        nil)))))
                   pathname))

Provides: WALK-DIRECTORY-TREE Requires: UIOP, WITH-RETRY https://github.com/stylewarning/quickutil/issues/65 Author: j3pic License: BSD