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

Dimitar Zhekov dimitar.zhekov at xxxxx
Sat Nov 6 12:45:46 UTC 2010

On Sat, 6 Nov 2010 21:31:31 +1100
Lex Trotman <elextr at gmail.com> wrote:

> On 6 November 2010 20:33, Dimitar Zhekov <dimitar.zhekov at gmail.com> wrote:
> >
> > 1. Open the file for reading and writing.
> I'm not sure all non-local filesystems support read/write or they
> support it via local caching which isn't safe until flushed to the
> remote system
> [...]
> The problem is that on local filesystems where its safe is where you
> don't need the performance and on remote filesystems where you need
> the performance you also need the safety.  Can't win.

Touchdown. OK, that's not worth.

> > if (G_UNLIKELY(len != bytes_written))
> >        err = errno;
> >
> > but fwrite() is not guaranteed to set errno, only write() is.
> Even write's behavoir is filesystem dependent IIUC.

Yes, but the documented behaviour of write(2) is to set errno, while
fwrite(2) does not. It's the same even for MSVCRT.

> > If not anything else, we should use non-buffered I/O, with fsync(), and
> > check the result of close() anyway.
> Yes.

Attached. I also rearranged the code a bit to restore the safe saving
support for Geany compiled with GIO. Since g_file_replace_contents() is
unsafe, there would be no harm have the old safe saving, at least until
we resolve the matter.

E-gards: Jimmy
-------------- next part --------------
A non-text attachment was scrubbed...
Name: write_data_fix.diff
Type: text/x-diff
Size: 1862 bytes
Desc: not available
URL: <http://lists.geany.org/pipermail/devel/attachments/20101106/c4763b75/attachment.diff>

More information about the Devel mailing list