/********************************************************************/
/* malloc with error checking. */
/********************************************************************/
/* malloc with error checking. */
ino_t inode;
int group_id; /* one per identical file content */
int dir_id; /* 1 for DIR1, and 2 for DIR2 */
ino_t inode;
int group_id; /* one per identical file content */
int dir_id; /* 1 for DIR1, and 2 for DIR2 */
char subname[PATH_MAX + 1];
if(lstat(name, &sb) != 0) {
char subname[PATH_MAX + 1];
if(lstat(name, &sb) != 0) {
- fprintf(stderr, "Can not stat \"%s\": %s\n", name, strerror(errno));
+ fprintf(stderr, "finddup: Can not stat \"%s\": %s\n", name, strerror(errno));
while((dir_e = readdir(dir))) {
if(!ignore_entry(dir_e->d_name)) {
snprintf(subname, PATH_MAX, "%s/%s", name, dir_e->d_name);
while((dir_e = readdir(dir))) {
if(!ignore_entry(dir_e->d_name)) {
snprintf(subname, PATH_MAX, "%s/%s", name, dir_e->d_name);
+struct file_node *scan_directory(struct file_node *tail, const char *name) {
+ struct file_node *result;
+ int length;
+
+ if(show_progress) {
+ fprintf(stderr, "Scanning '%s' ... ", name);
+ }
+
+ result = scan_directory_rec(tail, name);
+ length = file_list_length(result);
+
+ if(show_progress) {
+ fprintf(stderr, "done (%d file%s).\n",
+ length, (length > 1 ? "s" : ""));
+ }
+
+
+ return result;
+}
+
if(show_progress) {
/* We use the previous bar_width to compute the position, so that
we avoid doing too many ioctls */
if(show_progress) {
/* We use the previous bar_width to compute the position, so that
we avoid doing too many ioctls */
if(state->bar_width <= 0 || position != state->last_position) {
if(!ioctl (STDERR_FILENO, TIOCGWINSZ, (char *) &win)) {
/* Something weird is going on if the previous test is wrong */
if(state->bar_width <= 0 || position != state->last_position) {
if(!ioctl (STDERR_FILENO, TIOCGWINSZ, (char *) &win)) {
/* Something weird is going on if the previous test is wrong */
/* We need four % because of the fprintf that follows */
sprintf(s, " [%3d%%%%]\r",
/* We need four % because of the fprintf that follows */
sprintf(s, " [%3d%%%%]\r",
char *buffer1 = safe_malloc(sizeof(char) * READ_BUFFER_SIZE);
char *buffer2 = safe_malloc(sizeof(char) * READ_BUFFER_SIZE);
not_in = 0;
char *buffer1 = safe_malloc(sizeof(char) * READ_BUFFER_SIZE);
char *buffer2 = safe_malloc(sizeof(char) * READ_BUFFER_SIZE);
not_in = 0;
- if(show_progress) {
- list2_length = file_list_length(list2);
- fprintf(stderr, "done (%d file%s).\n",
- list2_length, (list2_length > 1 ? "s" : ""));
- }
fprintf(out, " -c, --hide-matchings do not show which files in DIR2 corresponds to\n");
fprintf(out, " those in DIR1\n");
fprintf(out, " -g, --no-group-ids do not show the file groups\n");
fprintf(out, " -c, --hide-matchings do not show which files in DIR2 corresponds to\n");
fprintf(out, " those in DIR1\n");
fprintf(out, " -g, --no-group-ids do not show the file groups\n");
fprintf(out, " -p, --show-progress show progress\n");
fprintf(out, " -r, --real-paths show the real file paths\n");
fprintf(out, " -i, --same-inodes-are-different\n");
fprintf(out, " -p, --show-progress show progress\n");
fprintf(out, " -r, --real-paths show the real file paths\n");
fprintf(out, " -i, --same-inodes-are-different\n");
/**********************************************************************/
static struct option long_options[] = {
/**********************************************************************/
static struct option long_options[] = {
{ "help", no_argument, 0, 'h' },
{ "same-inodes-are-different", no_argument, 0, 'i' },
{ "real-paths", no_argument, 0, 'r' },
{ "hide-matchings", no_argument, 0, 'c' },
{ "no-group-ids", no_argument, 0, 'g' },
{ "help", no_argument, 0, 'h' },
{ "same-inodes-are-different", no_argument, 0, 'i' },
{ "real-paths", no_argument, 0, 'r' },
{ "hide-matchings", no_argument, 0, 'c' },
{ "no-group-ids", no_argument, 0, 'g' },
{ "ignore-dots", no_argument, 0, 'd' },
{ "ignore-empty", no_argument, 0, '0' },
{ "show-progress", no_argument, 0, 'p' },
{ "ignore-dots", no_argument, 0, 'd' },
{ "ignore-empty", no_argument, 0, '0' },
{ "show-progress", no_argument, 0, 'p' },
- while ((c = getopt_long(argc, argv, "hircgd0pm",
+ while ((c = getopt_long(argc, argv, "vhircgtd0pm",