with-open-file problem of sbcl

Discussion of Common Lisp

Re: with-open-file problem of sbcl

Postby Wodin » Thu Sep 04, 2008 3:05 pm

deftsp wrote:
findinglisp wrote:I would post it to the SBCL developer's mailing list and see what they have to say.

Have you posted it to sbcl mailing list. I haven't see at gmane.lisp.steel-bank.devel.

deftsp: findinglisp meant "If I were you I would post...", i.e. he meant that you should post to the SBCL developers' mailing list.
Wodin
 
Posts: 56
Joined: Sun Jun 29, 2008 8:16 am

Re: with-open-file problem of sbcl

Postby Christopher Oliver » Fri Sep 05, 2008 5:55 pm

While the code below is undoubtedly an ugly vile hack, this is what I came up with on the spur of the moment. One things that makes me a bit unhappy aside from the fixed length buffer and the sloppy error handling* is that I'm not completely comfortable with read in this context. I'm not sure it's a great idea to assume that any of the file contents parse nicely as lisp data.

Code: Select all
(defun read-from-kernel-pseudo-file (file-name
                                     &optional (max-read 256))
  (with-open-file (in file-name)
    (let ((buf (make-array max-read
                           :element-type '(unsigned-byte 8))))
      (let ((actual (sb-unix:unix-read (sb-sys:fd-stream-fd in)
                                       (sb-sys:vector-sap buf)
                                       max-read)))
        (if (null actual)
            (error "Bad Unix read()")
            (read-from-string
              (sb-ext:octets-to-string (subseq buf 0 actual))))))))


* Remedy left as an exercise for the reader.
Christopher Oliver
 
Posts: 5
Joined: Fri Sep 05, 2008 2:05 pm

Re: with-open-file problem of sbcl

Postby deftsp » Fri Sep 05, 2008 8:04 pm

Wodin wrote:
deftsp wrote:
findinglisp wrote:I would post it to the SBCL developer's mailing list and see what they have to say.

Have you posted it to sbcl mailing list. I haven't see at gmane.lisp.steel-bank.devel.

deftsp: findinglisp meant "If I were you I would post...", i.e. he meant that you should post to the SBCL developers' mailing list.


Oh,sorry. That's my fault.
deftsp
 
Posts: 6
Joined: Tue Aug 05, 2008 6:16 am

Previous

Return to Common Lisp

Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest