static void compare_dir (WPanel * panel, WPanel * other, enum CompareMode mode) { int i, j; /* No marks by default */ panel->marked = 0; panel->total = 0; panel->dirs_marked = 0; /* Handle all files in the panel */ for (i = 0; i < panel->dir.len; i++) { file_entry_t *source = &panel->dir.list[i]; /* Default: unmarked */ file_mark (panel, i, 0); /* Skip directories */ if (S_ISDIR (source->st.st_mode)) continue; /* Search the corresponding entry from the other panel */ for (j = 0; j < other->dir.len; j++) { if (strcmp (source->fname, other->dir.list[j].fname) == 0) break; } if (j >= other->dir.len) /* Not found -> mark */ do_file_mark (panel, i, 1); else { /* Found */ file_entry_t *target = &other->dir.list[j]; if (mode != compare_size_only) { /* Older version is not marked */ if (source->st.st_mtime < target->st.st_mtime) continue; } /* Newer version with different size is marked */ if (source->st.st_size != target->st.st_size) { do_file_mark (panel, i, 1); continue; } if (mode == compare_size_only) continue; if (mode == compare_quick) { /* Thorough compare off, compare only time stamps */ /* Mark newer version, don't mark version with the same date */ if (source->st.st_mtime > target->st.st_mtime) { do_file_mark (panel, i, 1); } continue; } /* Thorough compare on, do byte-by-byte comparison */ { vfs_path_t *src_name, *dst_name; src_name = vfs_path_append_new (panel->cwd_vpath, source->fname, NULL); dst_name = vfs_path_append_new (other->cwd_vpath, target->fname, NULL); if (compare_files (src_name, dst_name, source->st.st_size)) do_file_mark (panel, i, 1); vfs_path_free (src_name); vfs_path_free (dst_name); } } } /* for (i ...) */ }
static void do_chown (uid_t u, gid_t g) { chown (current_panel->dir.list[current_file].fname, u, g); file_mark (current_panel, current_file, 0); }