void archive_entry_set_fflags(struct archive_entry *entry, unsigned long set, unsigned long clear) { archive_mstring_clean(&entry->ae_fflags_text); entry->ae_fflags_set = set; entry->ae_fflags_clear = clear; }
static void match_list_free(struct match_list *list) { struct match *p, *q; for (p = list->first; p != NULL; ) { q = p; p = p->next; archive_mstring_clean(&(q->pattern)); free(q); } }
static void entry_list_free(struct entry_list *list) { struct match_file *p, *q; for (p = list->first; p != NULL; ) { q = p; p = p->next; archive_mstring_clean(&(q->pathname)); free(q); } }
static int file_close(struct archive *a, void *client_data) { struct write_file_data *mine = (struct write_file_data *)client_data; (void)a; /* UNUSED */ if (mine->fd >= 0) close(mine->fd); archive_mstring_clean(&mine->filename); free(mine); return (ARCHIVE_OK); }
struct archive_entry * archive_entry_clear(struct archive_entry *entry) { if (entry == NULL) return (NULL); archive_mstring_clean(&entry->ae_fflags_text); archive_mstring_clean(&entry->ae_gname); archive_mstring_clean(&entry->ae_hardlink); archive_mstring_clean(&entry->ae_pathname); archive_mstring_clean(&entry->ae_sourcepath); archive_mstring_clean(&entry->ae_symlink); archive_mstring_clean(&entry->ae_uname); archive_entry_copy_mac_metadata(entry, NULL, 0); archive_acl_clear(&entry->acl); archive_entry_xattr_clear(entry); archive_entry_sparse_clear(entry); free(entry->stat); memset(entry, 0, sizeof(*entry)); return entry; }
static int add_entry(struct archive_match *a, int flag, struct archive_entry *entry) { struct match_file *f; const void *pathname; int r; f = calloc(1, sizeof(*f)); if (f == NULL) return (error_nomem(a)); #if defined(_WIN32) && !defined(__CYGWIN__) pathname = archive_entry_pathname_w(entry); if (pathname == NULL) { free(f); archive_set_error(&(a->archive), EINVAL, "pathname is NULL"); return (ARCHIVE_FAILED); } archive_mstring_copy_wcs(&(f->pathname), pathname); a->exclusion_tree.rbt_ops = &rb_ops_wcs; #else (void)rb_ops_wcs; pathname = archive_entry_pathname(entry); if (pathname == NULL) { free(f); archive_set_error(&(a->archive), EINVAL, "pathname is NULL"); return (ARCHIVE_FAILED); } archive_mstring_copy_mbs(&(f->pathname), pathname); a->exclusion_tree.rbt_ops = &rb_ops_mbs; #endif f->flag = flag; f->mtime_sec = archive_entry_mtime(entry); f->mtime_nsec = archive_entry_mtime_nsec(entry); f->ctime_sec = archive_entry_ctime(entry); f->ctime_nsec = archive_entry_ctime_nsec(entry); r = __archive_rb_tree_insert_node(&(a->exclusion_tree), &(f->node)); if (!r) { struct match_file *f2; /* Get the duplicated file. */ f2 = (struct match_file *)__archive_rb_tree_find_node( &(a->exclusion_tree), pathname); /* * We always overwrite comparison condition. * If you do not want to overwrite it, you should not * call archive_match_exclude_entry(). We cannot know * what behavior you really expect since overwriting * condition might be different with the flag. */ if (f2 != NULL) { f2->flag = f->flag; f2->mtime_sec = f->mtime_sec; f2->mtime_nsec = f->mtime_nsec; f2->ctime_sec = f->ctime_sec; f2->ctime_nsec = f->ctime_nsec; } /* Release the duplicated file. */ archive_mstring_clean(&(f->pathname)); free(f); return (ARCHIVE_OK); } entry_list_add(&(a->exclusion_entry_list), f); a->setflag |= TIME_IS_SET; return (ARCHIVE_OK); }