[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Non-Bug in Random File Access
Date: Thu, 10 Dec 87 12:52 EST
From: Barry Margolin <barmar@Think.COM>
Date: Wed, 9 Dec 87 16:30+0100
From: "Juergen Krey" <unido!gmdzi!LISPMemail@example.com>
The following bug concerns the Random Access File capability of Genera
7.1 . I tried to open a file in random access mode an another host with
the following code. There are no hints in Manual 5, that my options to
opening a file are inconsistent.
(defun do-it (&optional (path "aid:>krey>network>atu_2.lisp"))
(setq path (fs:parse-pathname path))
(with-open-file (in path :direction :input :direct t)
(read-record in 0 10)))
I think I remember this working in Rel 6.x
The problem is that you are opening a character stream instead of a
binary stream. Whenever you open a character stream to a file, the
Lispm always tries to read the attribute list (the -*- line at the
beginning). In the case of direct access streams this loses because it
hasn't done a :READ-BYTES first.
You'll have to add :element-type '(unsigned-byte 8) to your
WITH-OPEN-FILE, and change READ-RECORD to convert the bytes to
The bug here (shared with 6.1) is that it doesn't blow out with a nice
error message. You can't do direct characters because characters
take a variable number of bytes. (Consider CRLF on various systems,
never mind Rel 7 extended characters).
Release 7 offers various tools for encoding characters into bytes.
However, you will have to work with 1byte0 positions, not 1character