From 1ad73ec80373e6b1f98aa35ee52e236716b98a35 Mon Sep 17 00:00:00 2001 From: Adam Sutton Date: Tue, 9 Oct 2012 15:07:13 +0100 Subject: [PATCH] Modify hts_settings_remove to also remove (empty) dirs. --- src/settings.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/settings.c b/src/settings.c index eb33d5f2..8f0de39b 100644 --- a/src/settings.c +++ b/src/settings.c @@ -290,12 +290,18 @@ hts_settings_remove(const char *pathfmt, ...) { char fullpath[256]; va_list ap; + struct stat st; va_start(ap, pathfmt); hts_settings_buildpath(fullpath, sizeof(fullpath), pathfmt, ap, settingspath); va_end(ap); - unlink(fullpath); + if (stat(fullpath, &st) == 0) { + if (S_ISDIR(st.st_mode)) + rmdir(fullpath); + else + unlink(fullpath); + } } /**