From fc3312e6578efd62d5dd5f61715e56b578c0d4ee Mon Sep 17 00:00:00 2001 From: Attila Lendvai <attila.lendvai@gmail.com> Date: Fri, 8 Oct 2010 19:01:51 +0200 Subject: [PATCH] copy-sequence returns the number of bytes written --- io.lisp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/io.lisp b/io.lisp index 5df1619..59d6a8c 100644 --- a/io.lisp +++ b/io.lisp @@ -111,11 +111,13 @@ unless it's NIL, which means the system default." "Reads data from INPUT and writes it to OUTPUT. Both INPUT and OUTPUT must be streams, they will be passed to READ-SEQUENCE and WRITE-SEQUENCE and must have compatible element-types." - (loop - :for bytes-read = (read-sequence buffer input) - :while (= bytes-read buffer-size) - :do (write-sequence buffer output) - :finally (progn - (write-sequence buffer output :end bytes-read) - (when finish-output - (finish-output output))))) + (let ((bytes-written 0)) + (loop + :for bytes-read = (read-sequence buffer input) + :until (zerop bytes-read) + :do (progn + (write-sequence buffer output :end bytes-read) + (incf bytes-written bytes-read))) + (when finish-output + (finish-output output)) + bytes-written)) -- GitLab