diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2021-09-12 15:03:21 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2021-09-12 15:03:46 -0700 |
commit | 05531865dd9de53901cfa41917a8da4c13e2a303 (patch) | |
tree | 1933eaa67d4780d4bba5ec477b361013cfd7772a /src/property/file.lisp | |
parent | 9b606c973c3cf08217a805dbd453952eec9df5b1 (diff) | |
download | consfigurator-05531865dd9de53901cfa41917a8da4c13e2a303.tar.gz |
add FILE:LACKS-LINES-MATCHING
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
Diffstat (limited to 'src/property/file.lisp')
-rw-r--r-- | src/property/file.lisp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/property/file.lisp b/src/property/file.lisp index bdda926..9c4ad7d 100644 --- a/src/property/file.lisp +++ b/src/property/file.lisp @@ -78,6 +78,17 @@ replacing the contents of existing files, prefer FILE:HAS-CONTENT." path (curry #'remove-if (lambda (l) (member l lines :test #'string=)))))) +(defprop lacks-lines-matching :posix (path &rest patterns) + "If there is a file a PATH, ensure it does not contain any lines matching +any of the regular expressions PATTERNS." + (:apply + (let ((scanners (mapcar #'re:create-scanner patterns))) + (map-file-lines + path (lambda (lines) + (loop for line in lines + unless (loop for s in scanners thereis (re:scan s line)) + collect line)))))) + (defprop has-mode :posix (path mode) "Ensure that a file has a particular numeric mode." (:desc (format nil "~A has mode ~O" path mode)) |