chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-users] posix file-opening problem


From: Matt Gushee
Subject: [Chicken-users] posix file-opening problem
Date: Sun, 24 May 2009 13:02:09 -0600
User-agent: Thunderbird 2.0.0.19 (X11/20090213)

Hi, all--

I am having trouble opening files in append mode using posix functions
[Chicken 4.0 on Linux]:

csi> (define fd1 (file-open "/tmp/foo1.txt" (+ open/wronly open/creat)))
csi> (define po1 (open-output-file* fd1))
csi> (display "Hello 1\n" po1)
csi> (close-output-port po1)

csi> (define fd2 (file-open "/tmp/foo2.txt" (+ open/append open/creat)))
csi> (define po2 (open-output-file* fd2))

Error: (open-output-file*) cannot open file - Invalid argument: 3

        Call history:

        <syntax>          (define po2 (open-output-file* fd2))
        <syntax>          (##core#set! po2 (open-output-file* fd2))
        <syntax>          (open-output-file* fd2)
        <eval>            (open-output-file* fd2) <--

csi> (file-close fd2)

And it makes no difference--

  -- if "/tmp/foo2.txt" exists or not
  -- if I pass the #:append argument to open-output-file*

Is there something I don't understand about how to use open/append, or is this a bug?

BTW:

  * I later discovered that I can do

      (open-output-file "/tmp/foo2.txt" #:append)

    That meets my current need, but the above error is still worrisome.

  * Just out of curiosity, why does the open/rdonly flag exist? It
    evaluates to 0, just like open/read, and there is nothing to prevent
    someone from doing

      (+ open/rdonly open/write)

    Is it just to document the programmer's intentions?

--
Matt Gushee
: Bantam - lightweight file manager : matt.gushee.net/software/bantam/ :
: RASCL's A Simple Configuration Language :     matt.gushee.net/rascl/ :




reply via email to

[Prev in Thread] Current Thread [Next in Thread]