/**
- * Remove the directory given under @a option in
- * section [PATHS] in configuration under @a cfg_filename
+ * Helper function for #GNUNET_DISK_purge_cfg_dir.
*
- * @param cfg_filename configuration file to parse
- * @param option option with the dir name to purge
+ * @param cls a `const char *` with the option to purge
+ * @param cfg our configuration
+ * @return #GNUNET_OK on success
*/
-void
-GNUNET_DISK_purge_cfg_dir (const char *cfg_filename,
- const char *option)
+static int
+purge_cfg_dir (void *cls,
+ const struct GNUNET_CONFIGURATION_Handle *cfg)
{
- struct GNUNET_CONFIGURATION_Handle *cfg;
+ const char *option = cls;
char *tmpname;
-
- cfg = GNUNET_CONFIGURATION_create ();
- if (GNUNET_OK !=
- GNUNET_CONFIGURATION_load (cfg,
- cfg_filename))
- {
- GNUNET_break (0);
- GNUNET_CONFIGURATION_destroy (cfg);
- return;
- }
+
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_filename (cfg,
"PATHS",
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
"PATHS",
option);
- GNUNET_CONFIGURATION_destroy (cfg);
- return;
+ return GNUNET_NO;
}
- GNUNET_CONFIGURATION_destroy (cfg);
if (GNUNET_SYSERR ==
GNUNET_DISK_directory_remove (tmpname))
{
"remove",
tmpname);
GNUNET_free (tmpname);
- return;
+ return GNUNET_OK;
}
GNUNET_free (tmpname);
+ return GNUNET_OK;
}
+/**
+ * Remove the directory given under @a option in
+ * section [PATHS] in configuration under @a cfg_filename
+ *
+ * @param cfg_filename configuration file to parse
+ * @param option option with the dir name to purge
+ */
+void
+GNUNET_DISK_purge_cfg_dir (const char *cfg_filename,
+ const char *option)
+{
+ GNUNET_break (GNUNET_OK ==
+ GNUNET_CONFIGURATION_parse_and_run (cfg_filename,
+ &purge_cfg_dir,
+ (void *) option));
+}
+
/* end of disk.c */