Index: gconf/backends/markup-tree.c =================================================================== RCS file: /cvs/gnome/gconf/backends/markup-tree.c,v retrieving revision 1.18 diff -u -r1.18 markup-tree.c --- gconf/backends/markup-tree.c 9 Jun 2005 23:53:01 -0000 1.18 +++ gconf/backends/markup-tree.c 22 Aug 2005 23:44:31 -0000 @@ -3134,37 +3134,49 @@ GError **err) { GMarkupParseContext *context; + gchar *err_str; GError *error; ParseInfo info; char *filename; - char *text; gsize length; + FILE *f; + char text[4096]; filename = markup_dir_build_file_path (root, parse_subtree); parse_info_init (&info, root, parse_subtree); - text = NULL; - length = 0; + f = NULL; + err_str = NULL; error = NULL; - if (!g_file_get_contents (filename, &text, &length, &error)) - goto out; - /* Empty documents are OK */ - if (length == 0) + f = g_fopen(filename, "rb"); + if(!f) + { + err_str = g_strdup_printf (_("Failed to open \"%s\": %s\n"), + filename, g_strerror (errno)); goto out; - - g_assert (text); + } context = g_markup_parse_context_new (&gconf_parser, 0, &info, NULL); - error = NULL; - if (!g_markup_parse_context_parse (context, - text, - length, - &error)) - goto out; + while(!feof(f)) + { + length = fread(text, 1, sizeof(text), f); + if(length != sizeof(text) && !feof(f)) + { + err_str = g_strdup_printf (_("Couldn't read \"%s\": %s\n"), + filename, g_strerror (errno)); + goto out; + } + + error = NULL; + if (!g_markup_parse_context_parse (context, text, length, &error)) + { + goto out; + } + } error = NULL; if (!g_markup_parse_context_end_parse (context, &error)) @@ -3175,11 +3187,25 @@ out: g_free (filename); - g_free (text); + if(f) fclose(f); + + if (err_str) + { + if (error) + error = g_error_new_literal (GCONF_ERROR, + GCONF_ERROR_FAILED, + err_str); + + g_free (err_str); + } + parse_info_free (&info); if (error) + { g_propagate_error (err, error); + g_error_free(error); + } } /*