[Openmcl-devel] Transfer the contents of a file to a tcp stream
Christian Nybø
chr at nybo.no
Wed Jul 13 09:25:11 PDT 2005
Hello,
A function written in platform-independent CL barfs at times in
input-file-ioblock-advance. Seems there are times when a read-
sequence returns less than what it's asked
for, and this mismatch is detected by the advance function. I have
tried to narrow this down to an example where we copy the contents of
a file to another file, and set up lots of processes that each have
such a separate task.
With a directory "/Users/chr/Sites/formula/drobak/07-Images/"
containing some images, I can provoke the error by doing the
following. This is with ccl::*MULTIPROCESSING-SOCKET-IO* set to nil,
when it is set to t, similar errors are reported by CCL::OUTPUT-FILE-
FORCE-OUTPUT:
(defun stream-file (in out)
"Copy from pathname <in> to pathname <out>."
(with-open-file (is in :element-type '(unsigned-byte 8))
(with-open-file (os out
:direction :output
:if-exists :overwrite
:if-does-not-exist :create
:element-type '(unsigned-byte 8))
(loop with buffer-size = 2048
with buffer = (make-array buffer-size :element-type
'(unsigned-byte 8))
for nread = (read-sequence buffer is)
do (write-sequence buffer os :end nread)
while (= nread buffer-size)))))
(defun stream-file-process (pathname)
(process-run-function (format nil "slave-~A" (pathname-name
pathname))
#'stream-file pathname (pathname
(format nil "/tmp/foo.~A"
(pathname-name pathname)))))
(defun stream-file-process-directory (wild-pathname)
(mapcar #'stream-file-process
(directory wild-pathname)))
(defparameter *directory-with-certain-files*
#P"/Users/chr/Sites/formula/drobak/07-Images/*.jpg")
;; this one has trouble in input-file-ioblock-advance
(setf ccl::*MULTIPROCESSING-SOCKET-IO* nil)
(stream-file-process-directory *directory-with-certain-files*)
;; Could some of you alter *directory-with-certain-files*
;; and report back on whether this works on your systems?
Thanks,
--
chr
--
chr
More information about the Openmcl-devel
mailing list