[glib/wip/nacho/registry-writable: 4/5] registrybackend: get whether a backend is writable or not
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/wip/nacho/registry-writable: 4/5] registrybackend: get whether a backend is writable or not
- Date: Wed, 3 Feb 2016 20:22:20 +0000 (UTC)
commit 63f264245caebd53b660f3a65bead671b6859744
Author: Ignacio Casal Quinteiro <icq gnome org>
Date: Mon Feb 1 17:17:47 2016 +0100
registrybackend: get whether a backend is writable or not
gio/gregistrysettingsbackend.c | 27 ++++++++++++++++++++++++++-
1 files changed, 26 insertions(+), 1 deletions(-)
---
diff --git a/gio/gregistrysettingsbackend.c b/gio/gregistrysettingsbackend.c
index 672f6d0..5db797b 100644
--- a/gio/gregistrysettingsbackend.c
+++ b/gio/gregistrysettingsbackend.c
@@ -1126,11 +1126,35 @@ g_registry_backend_reset (GSettingsBackend *backend,
g_settings_backend_changed (backend, key_name, origin_tag);
}
-/* Not implemented and probably beyond the scope of this backend */
static gboolean
g_registry_backend_get_writable (GSettingsBackend *backend,
const gchar *key_name)
{
+ GRegistryBackend *self = G_REGISTRY_BACKEND (backend);
+ gchar *path_name, *value_name;
+ HKEY hpath;
+ LONG result;
+
+ path_name = parse_key (key_name, self->base_path, NULL);
+
+ /* Note: we create the key if it wasn't created yet, but it is not much
+ * of a problem since at the end of the day we have to create it anyway
+ * to read or to write from it
+ */
+ result = RegCreateKeyExA (HKEY_CURRENT_USER, path_name, 0, NULL, 0,
+ KEY_WRITE, NULL, &hpath, NULL);
+ if (result != ERROR_SUCCESS)
+ {
+ trace ("Error opening/creating key to check writability: %s.\n",
+ path_name);
+ g_free (path_name);
+
+ return FALSE;
+ }
+
+ g_free (path_name);
+ RegCloseKey (hpath);
+
return TRUE;
}
@@ -2020,6 +2044,7 @@ static void
g_registry_backend_init (GRegistryBackend *self)
{
RegistryCacheItem *item;
+
self->base_path = g_strdup_printf ("Software\\GSettings");
item = g_slice_new (RegistryCacheItem);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]