/* Initialize for a diff operation. */ void diff_init (void) { void *ptr; diff_buffer = page_aligned_alloc (&ptr, record_size); if (listed_incremental_option) read_directory_file (); }
void collect_and_sort_names (void) { struct name *name; struct name *next_name, *prev_name; int num_names; struct stat statbuf; Hash_table *nametab; name_gather (); if (!namelist) addname (".", 0, false, NULL); if (listed_incremental_option) { switch (chdir_count ()) { case 0: break; case 1: if (namelist->change_dir == 0) USAGE_ERROR ((0, 0, _("Using -C option inside file list is not " "allowed with --listed-incremental"))); break; default: USAGE_ERROR ((0, 0, _("Only one -C option is allowed with " "--listed-incremental"))); } read_directory_file (); } num_names = 0; for (name = namelist; name; name = name->next, num_names++) { if (name->found_count || name->directory) continue; if (name->matching_flags & EXCLUDE_WILDCARDS) /* NOTE: EXCLUDE_ANCHORED is not relevant here */ /* FIXME: just skip regexps for now */ continue; chdir_do (name->change_dir); if (name->name[0] == 0) continue; if (deref_stat (dereference_option, name->name, &statbuf) != 0) { stat_diag (name->name); continue; } if (S_ISDIR (statbuf.st_mode)) { name->found_count++; add_hierarchy_to_namelist (name, statbuf.st_dev, true); } } namelist = merge_sort (namelist, num_names, compare_names); num_names = 0; nametab = hash_initialize (0, 0, name_hash, name_compare, NULL); for (name = namelist; name; name = next_name) { next_name = name->next; name->caname = normalize_filename (name->name); if (prev_name) { struct name *p = hash_lookup (nametab, name); if (p) { /* Keep the one listed in the command line */ if (!name->parent) { if (p->child) rebase_child_list (p->child, name); /* FIXME: remove_directory (p->caname); ? */ remname (p); free_name (p); num_names--; } else { if (name->child) rebase_child_list (name->child, p); /* FIXME: remove_directory (name->caname); ? */ remname (name); free_name (name); continue; } } } name->found_count = 0; if (!hash_insert (nametab, name)) xalloc_die (); prev_name = name; num_names++; } nametail = prev_name; hash_free (nametab); namelist = merge_sort (namelist, num_names, compare_names_found); if (listed_incremental_option) { for (name = namelist; name && name->name[0] == 0; name++) ; if (name) append_incremental_renames (name->directory); } }
void collect_and_sort_names (void) { struct name *name; struct name *next_name; int counter; struct stat stat_info; name_gather (); if (listed_incremental_option) read_directory_file (); if (!name_list_head) add_name ("."); for (name = name_list_head; name; name = next_name) { next_name = name->next; if (name->match_found || name->dir_contents) continue; if (name->is_wildcard) /* FIXME: just skip wildcards for now */ continue; if (name->change_dir) if (chdir (name->change_dir) < 0) { ERROR ((0, errno, _("Cannot chdir to %s"), name->change_dir)); continue; } if ( #ifdef AIX statx (name->name, &stat_info, STATSIZE, STX_HIDDEN | STX_LINK) #else lstat (name->name, &stat_info) < 0 #endif ) { ERROR ((0, errno, _("Cannot stat %s"), name->name)); continue; } if (S_ISDIR (stat_info.st_mode)) { name->match_found = true; add_hierarchy_to_namelist (name->name, stat_info.st_dev); } } counter = 0; for (name = name_list_head; name; name = name->next) counter++; name_list_head = (struct name *) merge_sort ((voidstar) name_list_head, counter, (char *) (&(name_list_head->next)) - (char *) name_list_head, compare_names); for (name = name_list_head; name; name = name->next) name->match_found = false; if (listed_incremental_option) write_dir_file (); }
void collect_and_sort_names (void) { struct name *name; struct name *next_name; int num_names; struct stat statbuf; name_gather (); if (listed_incremental_option) read_directory_file (); if (!namelist) addname ("."); for (name = namelist; name; name = next_name) { next_name = name->next; if (name->found || name->dir_contents) continue; if (name->regexp) /* FIXME: just skip regexps for now */ continue; if (name->change_dir) if (chdir (name->change_dir) < 0) { ERROR ((0, errno, _("Cannot chdir to %s"), name->change_dir)); continue; } if ( #ifdef AIX statx (name->name, &statbuf, STATSIZE, STX_HIDDEN | STX_LINK) #else lstat (name->name, &statbuf) < 0 #endif ) { ERROR ((0, errno, _("Cannot stat %s"), name->name)); continue; } if (S_ISDIR (statbuf.st_mode)) { name->found = 1; add_hierarchy_to_namelist (name->name, statbuf.st_dev); } } num_names = 0; for (name = namelist; name; name = name->next) num_names++; namelist = (struct name *) merge_sort ((voidstar) namelist, num_names, (char *) (&(namelist->next)) - (char *) namelist, compare_names); for (name = namelist; name; name = name->next) name->found = 0; if (listed_incremental_option) write_dir_file (); }