On Wed, 10 Nov 2010 20:02:53 +0200 Dimitar Zhekov dimitar.zhekov@gmail.com wrote:
Ah, it sets errno = 0 first, assuming that fwrite() may fail to do so.
I've now committed a fix so that any write failure should be reported to the user even if errno is 0. Please test.
It won't be 0 unless you assign it. A successful library call does not clear errno.
Ok, but at least errors are now shown to the user.
But we should set errno=0 in case a confusing error message is shown.
Why fake 0 errno as EIO? g_file_set_contents() doesn't, and *strerror() returns something for 0, usually "Error 0".
GLib says to use g_strerror, which says 'Success', which is confusing.
fclose check is fixed now too.
If fwrite() and fclose() both fail, I'd prefer to see the errno of fwrite(), even if 0 (g_file_set_contents() does that).
Ok, but it might not set errno.
Hmmm, it'll be nice to display the filename as UTF-8 too, plus the name of the failed function, and we have a GError ready...
Mind if I try to improve the error handling, using gfileutils.c as a source? There will be 3 new translation strings.
Sure, have a go.
Nick