/* Default: Overwrite files, even if one on disk is newer. */
#define ARCHIVE_EXTRACT_NO_OVERWRITE_NEWER (2048)
-__LA_DECL int archive_read_extract(struct archive *, struct archive_entry *,
+__LA_DECL int archive_read_extract(struct archive *, struct archive_entry *,
int flags);
-__LA_DECL void archive_read_extract_set_progress_callback(struct archive *,
+__LA_DECL int archive_read_extract2(struct archive *, struct archive_entry *,
+ struct archive * /* dest */);
+__LA_DECL void archive_read_extract_set_progress_callback(struct archive *,
void (*_progress_func)(void *), void *_user_data);
/* Record the dev/ino of a file that will not be written. This is
.\" #endif
.Nm archive_read_data_into_fd ,
.Nm archive_read_extract ,
+.Nm archive_read_extract2 ,
.Nm archive_read_extract_set_progress_callback ,
.Nm archive_read_close ,
.Nm archive_read_finish
.Fa "struct archive_entry *"
.Fa "int flags"
.Fc
+.Ft int
+.Fo archive_read_extract2
+.Fa "struct archive *src"
+.Fa "struct archive_entry *"
+.Fa "struct archive *dest"
+.Fc
.Ft void
.Fo archive_read_extract_set_progress_callback
.Fa "struct archive *"
.Va flags
argument is passed unmodified to
.Xr archive_write_disk_set_options 3 .
+.It Fn archive_read_extract2
+This is another version of
+.Fn archive_read_extract
+that allows you to provide your own restore object.
+In particular, this allows you to override the standard lookup functions
+using
+.Xr archive_write_disk_set_group_lookup 3 ,
+and
+.Xr archive_write_disk_set_user_lookup 3 .
+Note that
+.Fn archive_read_extract2
+does not accept a
+.Va flags
+argument; you should use
+.Fn archive_write_disk_set_options
+to set the restore options yourself.
.It Fn archive_read_extract_set_progress_callback
Sets a pointer to a user-defined callback that can be used
for updating progress displays during extraction.
int
archive_read_extract(struct archive *_a, struct archive_entry *entry, int flags)
{
- struct archive_read *a = (struct archive_read *)_a;
struct extract *extract;
- int r, r2;
- extract = get_extract(a);
+ extract = get_extract((struct archive_read *)_a);
if (extract == NULL)
return (ARCHIVE_FATAL);
+ archive_write_disk_set_options(extract->ad, flags);
+ return (archive_read_extract2(_a, entry, extract->ad));
+}
+
+int
+archive_read_extract2(struct archive *_a, struct archive_entry *entry,
+ struct archive *ad)
+{
+ struct archive_read *a = (struct archive_read *)_a;
+ int r, r2;
/* Set up for this particular entry. */
- extract = a->extract;
- archive_write_disk_set_options(a->extract->ad, flags);
- archive_write_disk_set_skip_file(a->extract->ad,
+ archive_write_disk_set_skip_file(ad,
a->skip_file_dev, a->skip_file_ino);
- r = archive_write_header(a->extract->ad, entry);
+ r = archive_write_header(ad, entry);
if (r < ARCHIVE_WARN)
r = ARCHIVE_WARN;
if (r != ARCHIVE_OK)
/* If _write_header failed, copy the error. */
- archive_copy_error(&a->archive, extract->ad);
+ archive_copy_error(&a->archive, ad);
else
/* Otherwise, pour data into the entry. */
- r = copy_data(_a, a->extract->ad);
- r2 = archive_write_finish_entry(a->extract->ad);
+ r = copy_data(_a, ad);
+ r2 = archive_write_finish_entry(ad);
if (r2 < ARCHIVE_WARN)
r2 = ARCHIVE_WARN;
/* Use the first message. */
if (r2 != ARCHIVE_OK && r == ARCHIVE_OK)
- archive_copy_error(&a->archive, extract->ad);
+ archive_copy_error(&a->archive, ad);
/* Use the worst error return. */
if (r2 < r)
r = r2;