Libarchive tweaks to indicate data vs metadata reads and writes.

This commit is contained in:
Moinak Ghosh 2014-09-22 21:21:52 +05:30
parent 3debf1340c
commit 4c3f3d5ee2
3 changed files with 40 additions and 3 deletions

View file

@ -510,6 +510,14 @@ __LA_DECL int archive_read_set_option(struct archive *_a,
__LA_DECL int archive_read_set_options(struct archive *_a,
const char *opts);
/*
* This call has meaning inside a read or write client callback.
* It returns the metadata flag, which indicates whether the current
* request is for a metadata read/write. This allows clients filters
* to separately handle/store data and metadata.
*/
__LA_DECL int archive_request_is_metadata(struct archive *a);
/*-
* Convenience function to recreate the current entry (whose header
* has just been read) on disk.

View file

@ -119,6 +119,14 @@ struct archive {
unsigned current_codepage; /* Current ACP(ANSI CodePage). */
unsigned current_oemcp; /* Current OEMCP(OEM CodePage). */
struct archive_string_conv *sconv;
/*
* This flag is only used when invoking read/write callbacks. It
* tells the callback routine whether a metadata read or write is
* being requested. This lets higher-level processing routines to
* separately store/handle metadata and data.
*/
int cb_is_metadata;
};
/* Check magic value and state; return(ARCHIVE_FATAL) if it isn't valid. */

View file

@ -110,8 +110,13 @@ archive_read_finish(struct archive *a)
int
archive_write_header(struct archive *a, struct archive_entry *entry)
{
int rv;
++a->file_count;
return ((a->vtable->archive_write_header)(a, entry));
a->cb_is_metadata = 1;
rv = (a->vtable->archive_write_header)(a, entry);
a->cb_is_metadata = 0;
return (rv);
}
int
@ -141,13 +146,23 @@ archive_write_data_block(struct archive *a, const void *buff, size_t s, int64_t
int
archive_read_next_header(struct archive *a, struct archive_entry **entry)
{
return ((a->vtable->archive_read_next_header)(a, entry));
int rv;
a->cb_is_metadata = 1;
rv = (a->vtable->archive_read_next_header)(a, entry);
a->cb_is_metadata = 0;
return (rv);
}
int
archive_read_next_header2(struct archive *a, struct archive_entry *entry)
{
return ((a->vtable->archive_read_next_header2)(a, entry));
int rv;
a->cb_is_metadata = 1;
rv = (a->vtable->archive_read_next_header2)(a, entry);
a->cb_is_metadata = 0;
return (rv);
}
int
@ -156,3 +171,9 @@ archive_read_data_block(struct archive *a,
{
return ((a->vtable->archive_read_data_block)(a, buff, s, o));
}
int
archive_request_is_metadata(struct archive *a)
{
return (a->cb_is_metadata);
}