Add new mode letter to fopen()
Posted Mar 18, 2009 0:17 UTC (Wed) by quotemstr
In reply to: Add new mode letter to fopen()
Parent article: Better than POSIX?
FILE * f = fopen( "precious_config", "wf" );
All we need is a "t" flag. :-)
In all seriousness, I think that's the wrong level of abstraction for this functionality. A C
FILE* returned by
fopen should correspond to only one underlying file, and that file shouldn't magically change its name.
Besides, a flag to
open won't work because the kernel would have to spool modifications to that file until commit, and that would not only be very complex, but could open up all kind of denial-of-service attacks.
I wouldn't mind, however, a libc function that encapsulated the very common open-write-close-rename sequence. I wouldn't even mind some function that returned a
FILE*. I just don't think that function should be called
fopen, and don't think that FILE* shouldn't be closed with
fclose -- think of something more like
to post comments)