Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions utils.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,14 @@ location."
:test #'string=))

(defun copy-file (input output &key (if-exists :supersede))
(with-open-file (input-stream input)
(with-open-file (output-stream output :direction :output
(with-open-file (input-stream input :element-type '(unsigned-byte 8))
(with-open-file (output-stream output :element-type '(unsigned-byte 8)
:direction :output
:if-exists if-exists)
(loop for char = (read-char input-stream nil)
while char do (write-char char output-stream)))))
(let ((buf (make-array 4096 :element-type (stream-element-type input-stream))))
(loop for pos = (read-sequence buf input-stream)
while (plusp pos)
do (write-sequence buf output-stream :end pos))))))

(defun file-lines (file)
(with-open-file (stream file)
Expand Down