diff options
author | Thomas Haller <thaller@redhat.com> | 2015-06-13 21:42:46 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2015-06-13 21:43:01 +0200 |
commit | 6a31dd35ae7a19836732c38e03b11fc3ec571b8a (patch) | |
tree | 0dfc0f0e185152f2b1013ebdaa68d48a59fe8d7e | |
parent | 135999c2ec567683b6d71cc328584a2126167144 (diff) | |
download | NetworkManager-6a31dd35ae7a19836732c38e03b11fc3ec571b8a.tar.gz |
glib-compat: backport g_key_file_save_to_file()
-rw-r--r-- | include/nm-glib-compat.h | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/include/nm-glib-compat.h b/include/nm-glib-compat.h index 1dc939feac..f26c3fb959 100644 --- a/include/nm-glib-compat.h +++ b/include/nm-glib-compat.h @@ -163,4 +163,40 @@ q_n##_quark (void) \ } #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__ */ |