*
*/
#include <dirent.h>
+#include <fcntl.h>
#include <ftw.h>
#include <unistd.h>
#include <stdio.h>
return true;
}
+bool _bt_mesh_util_delete_file(const char *filename)
+{
+ struct stat st;
+ int fd;
+
+ fd = open(filename, O_RDONLY);
+ if (fd < 0) {
+ BT_ERR("Mesh: Failed to open [%s]", filename);
+ return false;
+ }
+
+ if (fstat(fd, &st) < 0) {
+ BT_ERR("Mesh: Failed to stat [%s]", filename);
+ close(fd);
+ return false;
+ }
+
+ if (S_ISREG(st.st_mode)) {
+ BT_INFO("Mesh: Failed stat: success [%s]", filename);
+ close(fd);
+ remove(filename);
+ return true;
+ } else {
+ BT_ERR("Mesh: [%s] Is not a regular file", filename);
+ }
+
+ BT_INFO("Mesh: File [%s] deleted", filename);
+ close(fd);
+ return false;
+}
+
bool _bt_mesh_util_is_directory_exists(const char *dir_path)
{
struct stat st;