summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2015-06-13 21:42:46 +0200
committerThomas Haller <thaller@redhat.com>2015-07-02 15:50:03 +0200
commit69f2d22bfe355f89b6ce9622613ab0e9be7d1dd1 (patch)
tree2663ad07ef729d90e933a58757ee3811465d146e
parentf8c9863d55d494bcf8613ded58e28636b48466b5 (diff)
downloadNetworkManager-69f2d22bfe355f89b6ce9622613ab0e9be7d1dd1.tar.gz
glib-compat: backport g_key_file_save_to_file()
-rw-r--r--include/nm-glib-compat.h37
1 files changed, 37 insertions, 0 deletions
diff --git a/include/nm-glib-compat.h b/include/nm-glib-compat.h
index 741d610319..dc39d2b934 100644
--- a/include/nm-glib-compat.h
+++ b/include/nm-glib-compat.h
@@ -213,4 +213,41 @@ _nm_g_ptr_array_insert (GPtrArray *array,
#endif
+#if !GLIB_CHECK_VERSION (2, 40, 0)
+inline static gboolean
+_g_key_file_save_to_file (GKeyFile *key_file,
+ const gchar *filename,
+ GError **error)
+{
+ gchar *contents;
+ gboolean success;
+ gsize length;
+
+ g_return_val_if_fail (key_file != NULL, FALSE);
+ g_return_val_if_fail (filename != NULL, FALSE);
+ g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
+
+ contents = g_key_file_to_data (key_file, &length, NULL);
+ g_assert (contents != NULL);
+
+ success = g_file_set_contents (filename, contents, length, error);
+ g_free (contents);
+
+ return success;
+}
+#define g_key_file_save_to_file(key_file, filename, error) \
+ _g_key_file_save_to_file (key_file, filename, error)
+#else
+#define g_key_file_save_to_file(key_file, filename, error) \
+ ({ \
+ gboolean _success; \
+ \
+ G_GNUC_BEGIN_IGNORE_DEPRECATIONS \
+ _success = g_key_file_save_to_file (key_file, filename, error); \
+ G_GNUC_END_IGNORE_DEPRECATIONS \
+ _success; \
+ })
+#endif
+
+
#endif /* __NM_GLIB_COMPAT_H__ */