From: Steve Jenson <stevej@po...> - 2005-09-03 04:47:51
Is this the expected behaviour when opening a bidirectional stream in
* (defparameter *db*
I suspect that I'm missing something obvious. Is there a more detailed
M that I can RTF?
/tmp/fixed-length.db is just a small ASCII file.
From: Juho Snellman <jsnell@ik...> - 2005-09-03 05:48:20
On Fri, Sep 02, 2005 at 09:47:15PM -0700, Steve Jenson wrote:
> Hi guys,
> Is this the expected behaviour when opening a bidirectional stream in
> SBCL 0.9.2:
> * (defparameter *db*
> (open "/tmp/fixed-length.db"
> :direction :io
> :if-does-not-exist :create
> :if-exists nil))
> * *db*
That's the expected behaviour when you're using :IF-EXISTS NIL and
the file exists.
if-exists specifies the action to be taken if direction is :output
or :io and a file of the name filespec already exists. If direction
is :input, not supplied, or :probe, if-exists is ignored. These are
the results of open as modified by if-exists:
No file or stream is created; instead, nil is returned to indicate
Maybe you want :IF-EXISTS :APPEND instead?
> I suspect that I'm missing something obvious. Is there a more detailed
> M that I can RTF?
The hyperspec page on OPEN.
From: Steve Jenson <stevej@po...> - 2005-09-03 07:12:11
On 9/2/05, Juho Snellman <jsnell@...> wrote:
> Maybe you want :IF-EXISTS :APPEND instead?
You are right, I brainfarted when reading the hyperspec, nil was wrong
and :append is better.
Thinking about this further, streams seem like the wrong abstraction
for what I'm doing. I am writing a generic record-based blob store.
Specifically, I'm rewriting the examples from the book "File
Structures" into CLOS.
It seems like I need more of a file descriptor abstraction: I want to
be able to seek to a specific location in the file and read and write
sequences and peek ahead when appropriate. I think I need to be
looking at the "sb-unix" package but all Google can find are patches
and socket discussion.
Thanks for your answer,
Steve Jenson <stevej@...> writes:
> Thinking about this further, streams seem like the wrong abstraction
> for what I'm doing. I am writing a generic record-based blob store.
> Specifically, I'm rewriting the examples from the book "File
> Structures" into CLOS.
File streams support the file-position function, which seeks to a
given position (which is a binary position if your stream is a binary
You don't want the sb-unix package unless you really know what you're
doing, because that's an implementation-private package. If you want
access to POSIX calls, you can use sb-posix, which is programmable (at
least in theory) by reading the Unix man pages and imagining how it
would be expressed in lisp...