[Openmcl-devel] Transfer the contents of a file to a tcp stream

Gary Byers gb at clozure.com
Fri Jul 15 17:52:06 PDT 2005


I'll take a look at this.  READ-SEQUENCE and WRITE-SEQUENCE can certainly
get short reads/writes; I'd thought that they both dealt with that, but
may be mistaken about that.


On Wed, 13 Jul 2005, [ISO-8859-1] Christian Nybø wrote:

> 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
>
> _______________________________________________
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
> http://clozure.com/mailman/listinfo/openmcl-devel
>
>


More information about the Openmcl-devel mailing list