Added recursive folder deleting function

pull/23/head
parent f954a62efa
commit 0ff7ad1478

@ -2124,6 +2124,29 @@ int yon_file_is_directory(const char *path)
return S_ISDIR(path_stat.st_mode);
}
void yon_dir_remove(const char *path){
DIR *d = opendir(path);
struct dirent *dir;
if (d) {
while ((dir = readdir(d)) != NULL) {
if (strcmp(dir->d_name, ".") == 0 || strcmp(dir->d_name, "..") == 0) {
continue;
}
char full_path[1024];
snprintf(full_path, sizeof(full_path), "%s/%s", path, dir->d_name);
if (dir->d_type == DT_DIR) {
yon_dir_remove(full_path);
} else {
unlink(full_path);
}
}
closedir(d);
rmdir(path);
}
}
// terminal-using functions
int yon_launch_app_with_arguments(char *name, char *args)

@ -616,6 +616,8 @@ config_str yon_file_ls(char *path, int *size);
int yon_file_is_directory(const char *path);
void yon_dir_remove(const char *path);
/** yon_dir_get_contents(char *dir_path, int *size)
* [EN]
*

Loading…
Cancel
Save