-#if 0
-static void copy_dir(void)
-{
- FILINFO from_stat;
- struct dirent *dp, **dir_list;
- int dir_cnt, i;
- char *old_from, *old_to;
-
-debug_cp("==== copy_file(): dne: %u\n", dne, );
-debug_cp(" from:'%s' to:'%s'\n", from->p_path, to.p_path);
-
- dir_cnt = scandir(from->p_path, &dir_list, NULL, NULL);
- if (dir_cnt == -1) {
- (void)fprintf(stderr, "%s: can't read directory %s.\n",
- progname, from->p_path);
- command_ret = CMD_RET_FAILURE;
- }
-
- /*
- * Instead of handling directory entries in the order they appear
- * on disk, do non-directory files before directory files.
- * There are two reasons to do directories last. The first is
- * efficiency. Files tend to be in the same cylinder group as
- * their parent, whereas directories tend not to be. Copying files
- * all at once reduces seeking. Second, deeply nested tree's
- * could use up all the file descriptors if we didn't close one
- * directory before recursivly starting on the next.
- */
- /* copy files */
- for (i = 0; i < dir_cnt; ++i) {
- dp = dir_list[i];
- if (dp->d_namlen <= 2 && dp->d_name[0] == '.'
- && (dp->d_name[1] == NULL || dp->d_name[1] == '.'))
- goto done;
- if (!(old_from =
- path_append(&from, dp->d_name, (int)dp->d_namlen)))
- goto done;
-
- if (statfcn(from->p_path, &from_stat) < 0) {
- err(PSTR("%s: %s"), dp->d_name, strerror(errno));
- path_restore(&from, old_from);
- goto done;
- }
- if (S_ISDIR(from_stat.st_mode)) {
- path_restore(&from, old_from);
- continue;
- }
- if (old_to = path_append(&to, dp->d_name, (int)dp->d_namlen)) {
- copy();
- path_restore(&to, old_to);
- }
- path_restore(&from, old_from);
-done: dir_list[i] = NULL;
- free(dp);
- }
-
- /* copy directories */
- for (i = 0; i < dir_cnt; ++i) {
- dp = dir_list[i];
- if (!dp)
- continue;
- if (!(old_from =
- path_append(&from, dp->d_name, (int)dp->d_namlen))) {
- free(dp);
- continue;
- }
- if (!(old_to =
- path_append(&to, dp->d_name, (int)dp->d_namlen))) {
- free(dp);
- path_restore(&from, old_from);
- continue;
- }
- copy();
- free(dp);
- path_restore(&from, old_from);
- path_restore(&to, old_to);
- }
- free(dir_list);
-}
-#endif