[Geany-devel] Changed file saving implementation for systems with GIO

Dimitar Zhekov dimitar.zhekov at xxxxx
Tue Nov 9 19:27:07 UTC 2010

On Tue, 9 Nov 2010 18:57:03 +0000
Nick Treleaven <nick.treleaven at btinternet.com> wrote:

> On Tue, 9 Nov 2010 20:28:43 +0200
> Dimitar Zhekov <dimitar.zhekov at gmail.com> wrote:
> > With binary I/O we have fsync(), which really flushes the data.
> > Even fflush() and fclose() are not guaranteed to do that.
> Strange, why is that?

fsync() is in section 2 system calls; you can't have such a function
in section 3. Closing a file (be it close or fclose) does not flush -
maybe for for performance reasons, dunno.

> > Well, g_file_set_contents() uses buffered I/O, so obviously it's
> > acceptable too.
> Yes, it uses fwrite and then errno.

Probably fwrite(), fflush() and then errno?
fflush() is guaranteed to set errno AFAIK.

> > But since we don't write the file line-by-line or
> > something, _why_ do we use buffered I/O in the first place?..
> I don't know. But changing implementation often introduces bugs, so
> I'm reluctant to do so (besides fixing fclose failure).

Well the current implementation is not exactly bug-free. :)

E-gards: Jimmy

More information about the Devel mailing list