summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/config/profiles.c35
1 files changed, 34 insertions, 1 deletions
diff --git a/src/config/profiles.c b/src/config/profiles.c
index 3c8abad..021df5e 100644
--- a/src/config/profiles.c
+++ b/src/config/profiles.c
@@ -309,10 +309,43 @@ mq_profiles_insert(MqProfiles *profiles, const gchar *name, const gchar *color)
}
}
+static gboolean
+unlink_recursive(const gchar *dir_path)
+{
+ GDir *dir;
+ const gchar *entry_name;
+ gchar *entry_path;
+
+ dir = g_dir_open(dir_path, 0, NULL);
+ if (!dir) {
+ return FALSE;
+ }
+
+ while ((entry_name = g_dir_read_name(dir))) {
+ entry_path = g_build_filename(dir_path, entry_name, NULL);
+ if (g_file_test(entry_path, G_FILE_TEST_IS_DIR)) {
+ unlink_recursive(entry_path);
+ }
+ if (g_unlink(entry_path) != 0) {
+ return FALSE;
+ }
+ g_free(entry_path);
+ }
+
+ g_dir_close(dir);
+ if (g_rmdir(dir_path) != 0) {
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
gboolean
mq_profiles_remove(MqProfiles *profiles, const gchar *profile)
{
- return g_key_file_remove_group(profiles->key_file, profile, NULL);
+ return unlink_recursive(
+ g_build_filename(profiles->config_dir, profile, NULL))
+ && g_key_file_remove_group(profiles->key_file, profile, NULL);
}
gboolean