diff options
Diffstat (limited to 'src/libnm-glib-aux/nm-keyfile-aux.c')
| -rw-r--r-- | src/libnm-glib-aux/nm-keyfile-aux.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/libnm-glib-aux/nm-keyfile-aux.c b/src/libnm-glib-aux/nm-keyfile-aux.c index 20a4690f..42f4f8be 100644 --- a/src/libnm-glib-aux/nm-keyfile-aux.c +++ b/src/libnm-glib-aux/nm-keyfile-aux.c @@ -485,3 +485,22 @@ nm_key_file_db_prune(NMKeyFileDB *self, } } } + +void +nm_key_file_add_group(GKeyFile *keyfile, const char *group) +{ + nm_assert(keyfile); + nm_assert(group); + + /* You can only call this function if the group doesn't exist yet. + * Because, we are about to add a dummy key, so we would have to + * be sure that the key doesn't exist. */ + nm_assert(!g_key_file_has_group(keyfile, group)); + + /* Ensure the group is present. + * There is no API for that, so add and remove a dummy key. + * For a profile it matters whether a setting is present or not, + * and we need to ensure that we persist the presence of the setting to keyfile*/ + g_key_file_set_value(keyfile, group, ".X", "1"); + g_key_file_remove_key(keyfile, group, ".X", NULL); +} |