Page 2 of 2
Re: with-open-file problem of sbcl
Posted: Thu Sep 04, 2008 3:05 pm
by Wodin
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.
Re: with-open-file problem of sbcl
Posted: Fri Sep 05, 2008 5:55 pm
by Christopher Oliver
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.
Re: with-open-file problem of sbcl
Posted: Fri Sep 05, 2008 8:04 pm
by deftsp
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.