ambrevar: Move match-extensions and match-name to `file'.

master
Pierre Neidhardt 2021-01-16 01:14:55 +01:00
parent c1bf82f25d
commit 5feda6addc
2 changed files with 19 additions and 19 deletions

View File

@ -196,6 +196,25 @@ Without PREDICATES, list all files."
(lambda (file)
(local-time:timestamp> (modification-date file) timestamp)))
(export-always 'match-extensions)
(defun match-extensions (extension &rest more-extensions)
"Return a predicate for files that match on of the provided extensions.
Useful for `finder'."
(lambda (file)
(some (lambda (ext)
(string= ext (extension 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 (basename file)))
(cons name more-names))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defparameter %magic-cookie-mime nil
"Internal storage for `magic-cookie-mime'.")

View File

@ -29,25 +29,6 @@
(delete-if #'sera:resolve-executable (cons program more-programs))))
(error "Missing programs: ~{~a~,^, ~}" missing-programs)))
(export-always 'match-extensions)
(defun match-extensions (extension &rest more-extensions)
"Return a predicate for files that match on of the provided extensions.
Useful for `finder'."
(lambda (file)
(some (lambda (ext)
(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.