GNOME Bugzilla – Bug 527979
GKeyfile has no obvious API for saving
Last modified: 2008-10-11 19:17:52 UTC
Are all applications supposed to do something along the lines below, when saving a keyfile? gchar *data; gsize data_size; if ((data = g_key_file_to_data (keyfile, &data_size, NULL))) { int fd; if ((fd = g_open (preset_path, O_WRONLY|O_CREAT|O_TRUNC))) { write(fd, data, data_size); close (fd); } g_free (data); } Shouldn't there be gboolean g_key_file_save_to_file (GKeyFile *key_file, const gchar *file, GError **error); If yes, I can make a patch (adding g_file_error handling above). Open question: * do we have a policy for creating backup files (safe rename and create) or should this be left to the application?
No, you are supposed to do this: gchar *data; gsize data_size; if ((data = g_key_file_to_data (keyfile, &data_size, NULL))) g_file_set_contents (preset_path, data, data_size, NULL) g_free (data); The policy you asked for is implemented by g_file_set_contents().
dup of bug #527979?
Sorry, I mean bug #309224
*** This bug has been marked as a duplicate of 309224 ***