deftsp: findinglisp meant "If I were you I would post...", i.e. he meant that you should post to the SBCL developers' mailing list.deftsp wrote:Have you posted it to sbcl mailing list. I haven't see at gmane.lisp.steel-bank.devel.findinglisp wrote:I would post it to the SBCL developer's mailing list and see what they have to say.
with-open-file problem of sbcl
Re: with-open-file problem of sbcl
-
- Posts: 5
- Joined: Fri Sep 05, 2008 2:05 pm
Re: with-open-file problem of sbcl
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.
* Remedy left as an exercise for the reader.
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))))))))
Re: with-open-file problem of sbcl
Oh,sorry. That's my fault.Wodin wrote:deftsp: findinglisp meant "If I were you I would post...", i.e. he meant that you should post to the SBCL developers' mailing list.deftsp wrote:Have you posted it to sbcl mailing list. I haven't see at gmane.lisp.steel-bank.devel.findinglisp wrote:I would post it to the SBCL developer's mailing list and see what they have to say.