1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
From siponen@amadeus.cs.hut.fi Thu May 19 13:29:19 EDT 1994
Article: 12818 of comp.lang.lisp
Xref: glinda.oz.cs.cmu.edu comp.lang.lisp:12818
Path: honeydew.srv.cs.cmu.edu!nntp.club.cc.cmu.edu!godot.cc.duq.edu!news.duke.edu!convex!cs.utexas.edu!howland.reston.ans.net!EU.net!sunic!news.funet.fi!sauna.cs.hut.fi!freenet.hut.fi!freenet.hut.fi!siponen
From: siponen@amadeus.cs.hut.fi (Lauri Siponen)
Newsgroups: comp.lang.lisp
Subject: Re: copy-file
Date: 16 May 1994 11:35:07 GMT
Organization: Freenet finland
Lines: 24
Message-ID: <SIPONEN.94May16143508@amadeus.cs.hut.fi>
References: <PCHU.94May12110013@kariba.bbn.com> <2r12bo$bim@underdog.jpl.nasa.gov>
<CpvIAM.1qr.3@cs.cmu.edu>
NNTP-Posting-Host: amadeus.cs.hut.fi
In-reply-to: ch+@cs.cmu.edu's message of Mon, 16 May 1994 02:15:58 GMT
dpANS introduces some new operations on streams. READ-SEQUENCE and
WRITE-SEQUENCE allow efficient I/O on files. This version of
copy-file copies multiple megabyte files easily. I ran it
on Allegro CL 4.2, SunOS 4.1.3.
(defun copy-file (source target)
;; Just an example!
(with-open-file (in source
:direction :input)
(with-open-file (out target
:direction :output
:if-exists :supersede)
(loop
with buffer = (make-string (* 64 512))
for n = (read-sequence buffer in)
until (= n 0)
do (write-sequence buffer out :end n)))))
READ-SEQUENCE and WRITE-SEQUENCE are not yet supported on every
Lisp implementation, but if they will be included in Lisp standard,
their availability should increase.
--
Lauri Siponen, Helsinki University of Technology
|