Abort if a file is non-existent - cl-yag - Common Lisp Yet Another website Gene… | |
git clone git://bitreich.org/cl-yag/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws… | |
Log | |
Files | |
Refs | |
Tags | |
README | |
LICENSE | |
--- | |
commit b0fb013bac0ad806bc90e487b552d3affa7f7413 | |
parent 994f2224eb625f71b68cb00a77edc37068f0f059 | |
Author: Solene Rapenne <[email protected]> | |
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(-) | |
--- | |
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 col… | |
+ "~" "~~") | |
+ (progn | |
+ (format t "ERROR : file ~a not found. Aborting~%" path) | |
+ (quit)))) | |
;; save a string in a file | |
(defun save-file(path data) |