Macro: WITH-OUTPUT-TO-FILE

Documentation

Evaluate BODY with STREAM-NAME to an output stream on the file named FILE-NAME. ARGS is sent as is to the call te open.

Source

(defmacro with-output-to-file ((stream-name file-name &rest args) &body body)
  "Evaluate BODY with STREAM-NAME to an output stream
  on the file named FILE-NAME. ARGS is sent as is to
  the call te open."
  (when (member :direction args)
    (error "Can't specifiy :DIRECTION in WITH-OUTPUT-FILE."))
  `(with-open-file (,stream-name ,file-name :direction :output ,@args)
     ,@body))
Source Context