51 #include <sys/types.h> 83 if (lstat(path, &sb) != 0)
85 if (! S_ISDIR(sb.st_mode))
86 return (unlink(path) ? 1 : 0);
96 while ((dent = readdir(dirp)) !=
NULL) {
97 if (strncmp(dent->d_name,
".", 2) == 0 ||
98 strncmp(dent->d_name,
"..", 3) == 0)
100 len = strlen(dent->d_name);
101 if (path_len + len + 2 >= max_len) {
104 strcpy(&path[path_len + 1], dent->d_name);
105 num_failures +=
do_unlink_tree(path, path_len + len + 1, max_len);
114 if (rmdir(path) != 0)
117 return (num_failures);
int unlink_tree(char *path)
static int do_unlink_tree(char *path, int path_len, int max_len)