+
+ if (prune_empty_dirs && no_dups && max_dir_depth) {
+ int j, cur_depth = 0;
+ int *maybe_dirs = new_array(int, max_dir_depth);
+
+ maybe_dirs[0] = -1;
+
+ for (i = flist->low; i <= flist->high; i++) {
+ struct file_struct *file = flist->files[i];
+
+ if (S_ISDIR(file->mode) && file->dir.depth) {
+ j = cur_depth;
+ cur_depth = file->dir.depth - 1;
+ for ( ; j >= cur_depth; j--) {
+ if (maybe_dirs[j] < 0)
+ continue;
+ clear_file(maybe_dirs[j], flist);
+ }
+ if (is_excluded(f_name(file, fbuf), 1,
+ ALL_FILTERS)) {
+ for (j = 0; j <= cur_depth; j++)
+ maybe_dirs[j] = -1;
+ } else
+ maybe_dirs[cur_depth] = i;
+ } else if (maybe_dirs[cur_depth] >= 0) {
+ for (j = 0; j <= cur_depth; j++)
+ maybe_dirs[j] = -1;
+ }
+ }
+ for (j = cur_depth; j >= 0; j--) {
+ if (maybe_dirs[j] < 0)
+ continue;
+ clear_file(maybe_dirs[j], flist);
+ }
+
+ for (i = flist->low; i <= flist->high; i++) {
+ if (flist->files[i]->basename)
+ break;
+ }
+ flist->low = i;
+ for (i = flist->high; i >= flist->low; i--) {
+ if (flist->files[i]->basename)
+ break;
+ }
+ flist->high = i;
+ }