Backport !3650 “gfileutils: Add a missing ftruncate() call when writing files” to glib-2-78
When calling g_file_set_contents_full()
without
G_FILE_SET_CONTENTS_CONSISTENT
, the file is written by opening it,
write()
ing to it, then closing it.
This is fine as long as the file is not longer than the new content you
want to set its contents to. If it is, the last bit of the old content
remains, because g_file_set_contents_full()
was missing an
ftruncate()
call.
Fix that, and change the tests to catch truncation failures in future.
Signed-off-by: Philip Withnall pwithnall@endlessos.org
Fixes: #3144 (closed)
(Backport 2.78: Unmark new translatable string as translatable, to avoid adding need for translations.)
Almost-trivial backport of !3650 (merged) to glib-2-78
. The only change is that I have removed the translation markers from the translatable string to avoid breaking string freeze.