diff options
Diffstat (limited to 'src/util/disk.c')
-rw-r--r-- | src/util/disk.c | 53 |
1 files changed, 52 insertions, 1 deletions
diff --git a/src/util/disk.c b/src/util/disk.c index 8fd689070..37d689576 100644 --- a/src/util/disk.c +++ b/src/util/disk.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2001--2013, 2016 GNUnet e.V. | 3 | Copyright (C) 2001--2013, 2016, 2018 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published | 6 | it under the terms of the GNU General Public License as published |
@@ -2641,4 +2641,55 @@ GNUNET_DISK_internal_file_handle_ (const struct GNUNET_DISK_FileHandle *fh, | |||
2641 | return GNUNET_OK; | 2641 | return GNUNET_OK; |
2642 | } | 2642 | } |
2643 | 2643 | ||
2644 | |||
2645 | /** | ||
2646 | * Remove the directory given under @a option in | ||
2647 | * section [PATHS] in configuration under @a cfg_filename | ||
2648 | * | ||
2649 | * @param cfg_filename configuration file to parse | ||
2650 | * @param option option with the dir name to purge | ||
2651 | */ | ||
2652 | void | ||
2653 | GNUNET_DISK_purge_cfg_dir (const char *cfg_filename, | ||
2654 | const char *option) | ||
2655 | { | ||
2656 | struct GNUNET_CONFIGURATION_Handle *cfg; | ||
2657 | char *tmpname; | ||
2658 | |||
2659 | cfg = GNUNET_CONFIGURATION_create (); | ||
2660 | if (GNUNET_OK != | ||
2661 | GNUNET_CONFIGURATION_load (cfg, | ||
2662 | cfg_filename)) | ||
2663 | { | ||
2664 | GNUNET_break (0); | ||
2665 | GNUNET_CONFIGURATION_destroy (cfg); | ||
2666 | return; | ||
2667 | } | ||
2668 | if (GNUNET_OK != | ||
2669 | GNUNET_CONFIGURATION_get_value_filename (cfg, | ||
2670 | "PATHS", | ||
2671 | option, | ||
2672 | &tmpname)) | ||
2673 | { | ||
2674 | GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, | ||
2675 | "PATHS", | ||
2676 | option); | ||
2677 | GNUNET_CONFIGURATION_destroy (cfg); | ||
2678 | return; | ||
2679 | } | ||
2680 | GNUNET_CONFIGURATION_destroy (cfg); | ||
2681 | if (GNUNET_SYSERR == | ||
2682 | GNUNET_DISK_directory_remove (tmpname)) | ||
2683 | { | ||
2684 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, | ||
2685 | "remove", | ||
2686 | tmpname); | ||
2687 | GNUNET_free (tmpname); | ||
2688 | return; | ||
2689 | } | ||
2690 | GNUNET_free (tmpname); | ||
2691 | } | ||
2692 | |||
2693 | |||
2694 | |||
2644 | /* end of disk.c */ | 2695 | /* end of disk.c */ |