diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2021-06-15 20:42:54 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2021-06-17 09:36:43 -0700 |
commit | 90cada65ede23058a133be570ababe0f4a87dcc8 (patch) | |
tree | bb83dad60c38ac9c0b8525be0326f647953f9de5 /src/property/file.lisp | |
parent | b24ff2c7365ee8d42063cbfa06ece3ef591d9a35 (diff) | |
download | consfigurator-90cada65ede23058a133be570ababe0f4a87dcc8.tar.gz |
add FILE:EXISTS-WITH-CONTENT
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
Diffstat (limited to 'src/property/file.lisp')
-rw-r--r-- | src/property/file.lisp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/property/file.lisp b/src/property/file.lisp index 58a99e6..8973de7 100644 --- a/src/property/file.lisp +++ b/src/property/file.lisp @@ -42,6 +42,20 @@ CONTENT can be a list of lines or a single string." (string (format nil "~A~&" content))) (and mode-supplied-p `(:mode ,mode))))) +(defpropspec exists-with-content :posix + (path content &key (mode nil mode-supplied-p)) + "Like FILE:HAS-CONTENT, but unapplicable, where unapplying means deleting +PATH, rather than restoring any old content it might have had. + +The semantics of this property are that if it is applied, the file has content +CONTENT, and if it is not applied to a host, the file does not exist. Thus, +it should be used to create new files on the host, not to replace the contents +of existing files, such as those installed by operating system packages. For +replacing the contents of existing files, prefer FILE:HAS-CONTENT." + `(with-unapply + (has-content ,path ,content ,@(and mode-supplied-p `(:mode ,mode))) + :unapply (does-not-exist ,path))) + (defprop contains-lines :posix (path &rest lines) "Ensure there is a file at PATH containing each of LINES once." (declare (indent 1)) |