From 7a76ef9be76f6c4521ad54d9a4a867e276ca872c Mon Sep 17 00:00:00 2001 From: Jaehyun Kim Date: Tue, 1 Nov 2022 12:37:54 +0900 Subject: [PATCH] DA: Remove all files in connman profile directory Connman profile cannot be deleted by deleting only data and settings files. Change-Id: Icf8c2d2814e88f2264ebe883bb67ba522456ad72 Signed-off-by: Jaehyun Kim --- src/wifi-config.c | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/src/wifi-config.c b/src/wifi-config.c index 6fa174c..def50d7 100755 --- a/src/wifi-config.c +++ b/src/wifi-config.c @@ -288,16 +288,37 @@ static gboolean __remove_file(const gchar *pathname, const gchar *filename) return ret; } +static gboolean __remove_all_files(const gchar *pathname) +{ + DIR *dir_ptr = NULL; + struct dirent *file = NULL; + + if ((dir_ptr = opendir(pathname)) == NULL) + return TRUE; + + while ((file = readdir(dir_ptr)) != NULL) { + if (strncmp(file->d_name, ".", 1) == 0 || strncmp(file->d_name, "..", 2) == 0) + continue; + + if (__remove_file(pathname, file->d_name) != TRUE) { + ERR("Cannot remove [%s/%s]", pathname, file->d_name); + closedir(dir_ptr); + + return FALSE; + } + } + + closedir(dir_ptr); + + return TRUE; +} + static gboolean __remove_configuration(const gchar *pathname) { int ret = 0; - if (__remove_file(pathname, "settings") != TRUE) { - ERR("Cannot remove [%s/settings]", pathname); - return FALSE; - } - if (__remove_file(pathname, "data") != TRUE) { - ERR("Cannot remove [%s/data]", pathname); + if (__remove_all_files(pathname) != TRUE) { + ERR("Cannot remove [%s] directory", pathname); return FALSE; } -- 2.34.1