From bee6215fe73e836feb1d49e00ecb960f33465e65 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Tue, 25 May 2021 17:21:06 -0700 Subject: store record of FASLs as Lisp data Signed-off-by: Sean Whitton --- src/util.lisp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/util.lisp') 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))))))) -- cgit v1.2.3