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
|
Use LF line endings for templates internally instead of default
|
||||||
pref because the default can change. This fixes missing line
|
pref because the default can change. This fixes missing line
|
||||||
endings sometimes when changing default setting.
|
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>
|
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_FILE_CREATE_NONE, NULL, NULL, &error);
|
||||||
g_object_unref(fp);
|
g_object_unref(fp);
|
||||||
#else
|
#else
|
||||||
gint err = 0;
|
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
gint bytes_written;
|
gint bytes_written;
|
||||||
|
gboolean fail = FALSE;
|
||||||
|
|
||||||
/* Use POSIX API for unsafe saving (GVFS-unsafe) */
|
/* Use POSIX API for unsafe saving (GVFS-unsafe) */
|
||||||
fp = g_fopen(locale_filename, "wb");
|
fp = g_fopen(locale_filename, "wb");
|
||||||
if (G_UNLIKELY(fp == NULL))
|
if (fp == NULL)
|
||||||
return g_strdup(g_strerror(errno));
|
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))
|
if (fclose(fp) != 0)
|
||||||
err = errno;
|
fail = TRUE;
|
||||||
|
}
|
||||||
fclose(fp);
|
if (fail)
|
||||||
|
{
|
||||||
if (err != 0)
|
gint err = errno;
|
||||||
|
if (!err)
|
||||||
|
err = EIO;
|
||||||
return g_strdup(g_strerror(err));
|
return g_strdup(g_strerror(err));
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user