ambrevar/shell: Add match-name.

master
Pierre Neidhardt 2020-12-11 21:54:47 +01:00
parent 2f6df66930
commit a122e66ece
1 changed files with 10 additions and 0 deletions

View File

@ -37,6 +37,16 @@ Useful for `finder'."
(string= ext (pathname-type file)))
(cons extension more-extensions))))
(export-always 'match-name)
(defun match-name (name &rest more-names)
"Return a predicate that matches when one of the names is contained in the
file basename.
Basename includes the extension. Useful for `finder'."
(lambda (file)
(some (lambda (name)
(str:contains? name (file-basename file)))
(cons name more-names))))
(export-always 'match-directory)
(defun match-directory (&key (empty? t) (non-empty? t) (files? t))
"Return a predicate that matches on directories.