;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*- (declaim (optimize (speed 0) (safety 3) (debug 3))) (in-package #:dns-admin) (defun compile-and-load (filename) "Compiles and then loads a file. `filename' should not have an extension, such as .fasl or .lisp." (compile-file filename) (load filename)) (defun file-to-list (infile) "Reads `infile' and returns a list, where each atom is a single line of the file. `infile' can be a string or a pathname object." (let ((infile-list ())) (with-open-file (filehandle infile :if-does-not-exist nil) (if (streamp filehandle) (progn (loop for line = (read-line filehandle nil) while line do (push line infile-list)) (nreverse infile-list)) nil)))) (defmacro dofile ((line filename) &body body) "Wrapper for the common task of opening a file and reading it one line at a time." (let ((stream (gensym))) `(with-open-file (,stream ,filename) (loop for ,line = (read-line ,stream nil nil) while ,line do ,@body))))