Abort if a file is non-existent - cl-yag - Common Lisp Yet Another website Generator HTML git clone git://bitreich.org/cl-yag/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/cl-yag/ DIR Log DIR Files DIR Refs DIR Tags DIR README DIR LICENSE --- DIR commit b0fb013bac0ad806bc90e487b552d3affa7f7413 DIR parent 994f2224eb625f71b68cb00a77edc37068f0f059 HTML Author: Solene Rapenne <solene@quafe.perso.pw> Date: Mon, 23 Jan 2017 15:00:40 +0100 Abort if a file is non-existent Diffstat: M generator.lisp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) --- DIR diff --git a/generator.lisp b/generator.lisp @@ -35,11 +35,15 @@ ;; load a file as a string ;; we escape ~ to avoid failures with format (defun load-file(path) - (replace-all - (strip-quotes - (with-open-file (stream path) - (loop for line = (read-line stream nil) while line collect line))) - "~" "~~")) + (if (probe-file path) + (replace-all + (strip-quotes + (with-open-file (stream path) + (loop for line = (read-line stream nil) while line collect line))) + "~" "~~") + (progn + (format t "ERROR : file ~a not found. Aborting~%" path) + (quit)))) ;; save a string in a file (defun save-file(path data)