[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: file:write() fails silently for read-only files
- From: Reuben Thomas <rrt@...>
- Date: Thu, 8 Sep 2011 12:24:19 +0100
On 8 September 2011 11:54, Tony Finch <dot@dotat.at> wrote:
> On Thu 8 Sep 2011, at 11:47, steve donovan wrote:
>>
>> I assumed that it did, thanks for correcting that. The portable C way
>> is to check what the number of bytes which fwrite returns.
>
>
> In my tests (on Mac OS X) fprintf() writing to a FILE* stream open for reading returns a successful result, but errno and the ferror() flag are set.
>
I got a contradictory result:
$ cat foo.c
#include <stdio.h>
int main (void)
{
FILE *f = fopen("foo", "r");
int ret = fprintf(f, "dfoo");
printf ("%d %d\n", ret, ferror(f));
}
$ gcc -o foo foo.c
$ ./foo
-1 1
--
http://rrt.sc3d.org
- References:
- file:write() fails silently for read-only files, HyperHacker
- Re: file:write() fails silently for read-only files, startx
- Re: file:write() fails silently for read-only files, HyperHacker
- Re: file:write() fails silently for read-only files, startx
- Re: file:write() fails silently for read-only files, steve donovan
- Re: file:write() fails silently for read-only files, Enrico Colombini
- Re: file:write() fails silently for read-only files, Josh Simmons
- Re: file:write() fails silently for read-only files, Josh Simmons
- Re: file:write() fails silently for read-only files, steve donovan
- Re: file:write() fails silently for read-only files, liam mail
- Re: file:write() fails silently for read-only files, steve donovan
- Re: file:write() fails silently for read-only files, Tony Finch