diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2021-05-25 17:21:06 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2021-05-25 17:21:06 -0700 |
commit | bee6215fe73e836feb1d49e00ecb960f33465e65 (patch) | |
tree | e0a36ab2aac3e7356b475cf973362483b8434d7b /src/util.lisp | |
parent | 7454e3a739fb14526b3d9d01f76c91396c2de17a (diff) | |
download | consfigurator-bee6215fe73e836feb1d49e00ecb960f33465e65.tar.gz |
store record of FASLs as Lisp data
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
Diffstat (limited to 'src/util.lisp')
-rw-r--r-- | src/util.lisp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/util.lisp b/src/util.lisp index cd59fb7..3260de0 100644 --- a/src/util.lisp +++ b/src/util.lisp @@ -363,3 +363,17 @@ of this macro." "Cancel the CLEANUP forms in all enclosing uses of UNWIND-PROTECT-IN-PARENT. Should be called soon after fork(2) in child processes." (signal 'in-child-process)) + + +;;;; Lisp data files + +(defmacro with-lisp-data-file ((data file) &body forms) + (with-gensyms (before) + `(let* ((,before (and (file-exists-p ,file) (read-file-string ,file))) + (,data (and ,before (plusp (length ,before)) + (safe-read-from-string ,before)))) + (unwind-protect-in-parent (progn ,@forms) + (with-open-file + (stream ,file :direction :output :if-exists :supersede) + (with-standard-io-syntax + (prin1 ,data stream))))))) |