Fix not reporting an error message when saving a document fails.
Check result of fclose(). git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@5391 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
parent
9aa94483b6
commit
1355795908
@ -4,6 +4,9 @@
|
||||
Use LF line endings for templates internally instead of default
|
||||
pref because the default can change. This fixes missing line
|
||||
endings sometimes when changing default setting.
|
||||
* src/document.c:
|
||||
Fix not reporting an error message when saving a document fails.
|
||||
Check result of fclose().
|
||||
|
||||
|
||||
2010-11-09 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
|
||||
|
@ -1725,24 +1725,31 @@ static gchar *write_data_to_disk(const gchar *locale_filename,
|
||||
G_FILE_CREATE_NONE, NULL, NULL, &error);
|
||||
g_object_unref(fp);
|
||||
#else
|
||||
gint err = 0;
|
||||
FILE *fp;
|
||||
gint bytes_written;
|
||||
gboolean fail = FALSE;
|
||||
|
||||
/* Use POSIX API for unsafe saving (GVFS-unsafe) */
|
||||
fp = g_fopen(locale_filename, "wb");
|
||||
if (G_UNLIKELY(fp == NULL))
|
||||
return g_strdup(g_strerror(errno));
|
||||
if (fp == NULL)
|
||||
fail = TRUE;
|
||||
else
|
||||
{
|
||||
bytes_written = fwrite(data, sizeof(gchar), len, fp);
|
||||
|
||||
bytes_written = fwrite(data, sizeof(gchar), len, fp);
|
||||
if (len != bytes_written)
|
||||
fail = TRUE;
|
||||
|
||||
if (G_UNLIKELY(len != bytes_written))
|
||||
err = errno;
|
||||
|
||||
fclose(fp);
|
||||
|
||||
if (err != 0)
|
||||
if (fclose(fp) != 0)
|
||||
fail = TRUE;
|
||||
}
|
||||
if (fail)
|
||||
{
|
||||
gint err = errno;
|
||||
if (!err)
|
||||
err = EIO;
|
||||
return g_strdup(g_strerror(err));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
|
Loading…
x
Reference in New Issue
Block a user