/* * returns number of the sparse entries */ int archive_entry_sparse_count(struct archive_entry *entry) { struct ae_sparse *sp; int count = 0; for (sp = entry->sparse_head; sp != NULL; sp = sp->next) count++; /* * Sanity check if this entry is exactly sparse. * If amount of sparse blocks is just one and it indicates the whole * file data, we should remove it and return zero. */ if (count == 1) { sp = entry->sparse_head; if (sp->offset == 0 && sp->length >= archive_entry_size(entry)) { count = 0; archive_entry_sparse_clear(entry); } } return (count); }
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; }