`g_file_set_contents_full()` doesn't truncate the file (without `G_FILE_SET_CONTENTS_CONSISTENT`)
If the file already exists and is longer than the new content, previous content is left at the end of the file - unless G_FILE_SET_CONTENTS_CONSISTENT
flag is set.
And I can't find any code that could truncate the file in g_file_set_contents_full()
/write_to_file()
.
#include <glib.h>
int main(void) {
const char long_content[] = "abcdefgh";
const char short_content[] = "jhki";
g_file_set_contents_full("test.txt", long_content, -1, G_FILE_SET_CONTENTS_NONE, 0644, NULL);
g_file_set_contents_full("test.txt", short_content, -1, G_FILE_SET_CONTENTS_NONE, 0644, NULL);
return 0;
}
expected:
$ cat test.txt
jhki
actual:
$ cat test.txt
jhkiefgh
Edited by Aleksandr Mezin