[Openmcl-devel] make-fd-stream

Gary Byers gb at clozure.com
Sun Sep 25 22:11:07 PDT 2005



On Sun, 25 Sep 2005 julian at cipht.net wrote:

> On Sun, Sep 25, 2005 at 01:42:13PM -0600, Gary Byers wrote:
>> CCL::MAKE-FD-STREAM creates a Gray stream; all streams in OpenMCL are
>> Gray streams, and STREAMP returns T when applied to any of them.
>> (This has nothing to do with CMUCL's fd-streams as I remember them; it
>> happens to be the case that many interestring subclasses of STREAM -
>> including file streams and network sockets - operate on file
>> descriptors, and CCL::MAKE-FD-STREAM handles many of the buffer
>> creation and other details that're common to those classes.
>
> Ah, my mistake.  I was testing the source of my problem incorrectly.
> Indeed, I do get a stream back, but when I try to seek in it with
> FILE-POSITION, I get:
>
>> Error in process listener(1): value #<FD-CHARACTER-IO-STREAM (FILE/4)
>> #x3547EB06> is not of the expected type STREAM.
>> While executing: #<CCL::STANDARD-KERNEL-METHOD CCL::STREAM-POSITION
>> (T)>
>

The error message is a little confusing; there should probably be
a CCL::STREAM-POSITION method on STREAM that complains that the
particular class of stream isn't seekable.

> I guess that the streams returned by MAKE-FD-STREAM aren't seekable?

MAKE-FD-STREAM takes a :CLASS argument, which is intended to be an
abstract class from which (based on the :direction and :element-type
arguments) a concrete subclass is derived.  This argument defaults
to 'CCL::FD-STREAM; you probably want to pass 'FILE-STREAM here.

(let* ((fd (%open-fd-to-temporary-file)))
    (ccl::make-fd-stream fd
                         :direction :output
                         :element-type whatever
                         :class 'file-stream))

The result should be an instance of some subclass of FILE-STREAM,
fully capable of seeking.


> Please excuse my cluelessness on this matter.
>
>> (I wasn't planning on changing CCL::MAKE-FD-STREAM, either.)
>
> Good to know.
>
> Thanks.
>
> -- 
> Julian Squires
>
>



More information about the Openmcl-devel mailing list