diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2021-04-04 22:18:06 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2021-04-04 22:18:06 -0700 |
commit | e7dbb5a99d6bad042da868f0b6f485aaeaa178a3 (patch) | |
tree | 544cd697b1b23502a9113ee73f6ed2d2a3c1cbc2 | |
parent | ea0adb3ef8386bd50fee2bea5dba3ce091378227 (diff) | |
download | consfigurator-e7dbb5a99d6bad042da868f0b6f485aaeaa178a3.tar.gz |
FILE:HAS-CONTENT: support :MODE argument
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
-rw-r--r-- | src/property/file.lisp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/property/file.lisp b/src/property/file.lisp index a959120..c59d79e 100644 --- a/src/property/file.lisp +++ b/src/property/file.lisp @@ -29,16 +29,20 @@ point in doing that here because WRITEFILE is synchronous." :no-change (writefile file (unlines new-lines))))) -(defprop has-content :posix (path content) +(defprop has-content :posix (path content &key (mode nil mode-supplied-p)) "Ensure there is a file at PATH whose content is CONTENT. CONTENT can be a list of lines or a single string." (declare (indent 1)) - (:desc (declare (ignore content)) + (:desc (declare (ignore content mode mode-supplied-p)) #?"${path} has defined content") (:apply (with-change-if-changes-file-content (path) - (writefile path (etypecase content - (cons (unlines content)) - (string (format nil "~A~&" content))))))) + (let ((args (list path + (etypecase content + (cons (unlines content)) + (string (format nil "~A~&" content)))))) + (when mode-supplied-p + (nconcf args (list :mode mode))) + (apply #'writefile args))))) (defprop contains-lines :posix (path &rest lines) "Ensure there is a file at PATH containing each of LINES once." |