summaryrefslogtreecommitdiffstats
path: root/src/config
diff options
context:
space:
mode:
authorPatrick McDermott <pj@pehjota.net>2017-11-10 11:58:53 (EST)
committer Patrick McDermott <pj@pehjota.net>2017-11-10 12:19:02 (EST)
commitbabd9857027a20ac25d373a6378cceaf417e2634 (patch)
treed16c0dc74b09e581156e83dfcaaede10522a11b3 /src/config
parent30449ce7afd4c9d33c17bc22eebae2bb01cff3f5 (diff)
downloadmarquee-babd9857027a20ac25d373a6378cceaf417e2634.zip
marquee-babd9857027a20ac25d373a6378cceaf417e2634.tar.gz
marquee-babd9857027a20ac25d373a6378cceaf417e2634.tar.bz2
mq_profiles_remove(): Remove profile directory
Diffstat (limited to 'src/config')
-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