chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] posix file-opening problem


From: Jim Ursetto
Subject: Re: [Chicken-users] posix file-opening problem
Date: Sun, 24 May 2009 20:04:22 -0500

On Sun, May 24, 2009 at 2:02 PM, Matt Gushee <address@hidden> wrote:
> Hi, all--
>
> I am having trouble opening files in append mode using posix functions
> [Chicken 4.0 on Linux]:
>
> 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

file-open is a direct interface to open(2).  One of the access mode
flags open/rdonly, open/wronly or open/rdwr must be specified.
open/append is a modifier (status flag), as is open/creat (creation
flag).

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

>  * 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)

Blame the underlying open(2) interface for this idiosyncrasy.

Note open/read and open/write are synonyms for open/rdonly [O_RDONLY]
and open/wronly [O_WRONLY].

Jim




reply via email to

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