1 | (in-package #:abcl.test.lisp) |
---|
2 | ;;; From CL-FAD |
---|
3 | (defvar *stream-buffer-size* 8192) |
---|
4 | (defun cl-fad-copy-stream (from to &optional (checkp t)) |
---|
5 | "Copies into TO \(a stream) from FROM \(also a stream) until the end |
---|
6 | of FROM is reached, in blocks of *stream-buffer-size*. The streams |
---|
7 | should have the same element type. If CHECKP is true, the streams are |
---|
8 | checked for compatibility of their types." |
---|
9 | (when checkp |
---|
10 | (unless (subtypep (stream-element-type to) (stream-element-type from)) |
---|
11 | (error "Incompatible streams ~A and ~A." from to))) |
---|
12 | (let ((buf (make-array *stream-buffer-size* |
---|
13 | :element-type (stream-element-type from)))) |
---|
14 | (loop |
---|
15 | (let ((pos (read-sequence buf from))) |
---|
16 | (when (zerop pos) (return)) |
---|
17 | (write-sequence buf to :end pos)))) |
---|
18 | (values)) |
---|
19 | |
---|
20 | (defun cl-fad-copy-file (from to &key overwrite) |
---|
21 | "Copies the file designated by the non-wild pathname designator FROM |
---|
22 | to the file designated by the non-wild pathname designator TO. If |
---|
23 | OVERWRITE is true overwrites the file designtated by TO if it exists." |
---|
24 | (let ((element-type '(unsigned-byte 8))) |
---|
25 | (with-open-file (in from :element-type element-type) |
---|
26 | (with-open-file (out to :element-type element-type |
---|
27 | :direction :output |
---|
28 | :if-exists (if overwrite |
---|
29 | :supersede :error)) |
---|
30 | (cl-fad-copy-stream in out)))) |
---|
31 | (values)) |
---|
32 | |
---|
33 | (defvar *foo.lisp* |
---|
34 | `(defun foo () |
---|
35 | (labels ((output () |
---|
36 | (format t "FOO here."))) |
---|
37 | (output)))) |
---|
38 | |
---|
39 | (defmacro with-temp-directory ((directory) &rest body) |
---|
40 | `(let ((*default-pathname-defaults* *abcl-test-directory*)) |
---|
41 | (ensure-directories-exist ,directory) |
---|
42 | (prog1 |
---|
43 | ,@body |
---|
44 | (delete-directory-and-files ,directory)))) |
---|
45 | |
---|