@@ -2253,24 +2253,6 @@ bool mesh_config_load_nodes(const char *cfgdir_name, mesh_config_node_func_t cb,
return true;
}
-static int del_fobject(const char *fpath, const struct stat *sb, int typeflag,
- struct FTW *ftwbuf)
-{
- switch (typeflag) {
- case FTW_DP:
- rmdir(fpath);
- l_debug("RMDIR %s", fpath);
- break;
-
- case FTW_SL:
- default:
- remove(fpath);
- l_debug("RM %s", fpath);
- break;
- }
- return 0;
-}
-
void mesh_config_destroy(struct mesh_config *cfg)
{
char *node_dir, *node_name;
@@ -2291,7 +2273,7 @@ void mesh_config_destroy(struct mesh_config *cfg)
if (strcmp(node_name, uuid))
return;
- nftw(node_dir, del_fobject, 5, FTW_DEPTH | FTW_PHYS);
+ del_path(node_dir);
/* Release node config object */
mesh_config_release(cfg);
@@ -24,6 +24,7 @@
#define _GNU_SOURCE
#include <dirent.h>
#include <ftw.h>
+#include <unistd.h>
#include <stdio.h>
#include <limits.h>
#include <time.h>
@@ -129,3 +130,27 @@ int create_dir(const char *dir_name)
return 0;
}
+
+static int del_fobject(const char *fpath, const struct stat *sb, int typeflag,
+ struct FTW *ftwbuf)
+{
+ switch (typeflag) {
+ case FTW_DP:
+ rmdir(fpath);
+ l_debug("RMDIR %s", fpath);
+ break;
+
+ case FTW_SL:
+ default:
+ remove(fpath);
+ l_debug("RM %s", fpath);
+ break;
+ }
+ return 0;
+}
+
+
+void del_path(const char *path)
+{
+ nftw(path, del_fobject, 5, FTW_DEPTH | FTW_PHYS);
+}
@@ -23,3 +23,4 @@ bool str2hex(const char *str, uint16_t in_len, uint8_t *out,
size_t hex2str(uint8_t *in, size_t in_len, char *out, size_t out_len);
void print_packet(const char *label, const void *data, uint16_t size);
int create_dir(const char *dir_name);
+void del_path(const char *path);