From 2032baa561c7fefbe2605f5d6b979a295a61637d Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Wed, 9 Oct 2013 10:05:42 +0000 Subject: migrating towards XDG configuration specification (#3000) --- src/statistics/gnunet-service-statistics.c | 36 +++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 10 deletions(-) (limited to 'src/statistics/gnunet-service-statistics.c') diff --git a/src/statistics/gnunet-service-statistics.c b/src/statistics/gnunet-service-statistics.c index acf2a965f..6c3d173c4 100644 --- a/src/statistics/gnunet-service-statistics.c +++ b/src/statistics/gnunet-service-statistics.c @@ -241,11 +241,20 @@ load (struct GNUNET_SERVER_Handle *server) struct GNUNET_SERVER_MessageStreamTokenizer *mst; char *emsg; - fn = GNUNET_DISK_get_home_filename (cfg, "statistics", "statistics.data", - NULL); - if (fn == NULL) + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_filename (cfg, + "STATISTICS", + "DATABASE", + &fn)) + { + GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, + "STATISTICS", + "DATABASE"); return; - if ((GNUNET_OK != GNUNET_DISK_file_size (fn, &fsize, GNUNET_NO, GNUNET_YES)) || (fsize == 0)) + } + if ( (GNUNET_OK != + GNUNET_DISK_file_size (fn, &fsize, GNUNET_NO, GNUNET_YES)) || + (0 == fsize) ) { GNUNET_free (fn); return; @@ -291,15 +300,22 @@ save () struct StatsEntry *pos; char *fn; struct GNUNET_BIO_WriteHandle *wh; - uint16_t size; unsigned long long total; - wh = NULL; - fn = GNUNET_DISK_get_home_filename (cfg, "statistics", "statistics.data", - NULL); - if (fn != NULL) - wh = GNUNET_BIO_write_open (fn); + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_filename (cfg, + "STATISTICS", + "DATABASE", + &fn)) + { + GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, + "STATISTICS", + "DATABASE"); + return; + } + (void) GNUNET_DISK_directory_create_for_file (fn); + wh = GNUNET_BIO_write_open (fn); total = 0; while (NULL != (pos = start)) { -- cgit v1.2.3