diff options
author | kientzle <kientzle@FreeBSD.org> | 2006-09-05 05:59:46 +0000 |
---|---|---|
committer | kientzle <kientzle@FreeBSD.org> | 2006-09-05 05:59:46 +0000 |
commit | b70eb6239fc6c06b97d3bc78e4e84e977147c7b3 (patch) | |
tree | e9e5403d1ee6b34e31b33c6371840038b4f4874e /lib/libarchive/archive_write.c | |
parent | 0eaa9fd1daf7600660f11f644e7adf331290e11d (diff) | |
download | FreeBSD-src-b70eb6239fc6c06b97d3bc78e4e84e977147c7b3.zip FreeBSD-src-b70eb6239fc6c06b97d3bc78e4e84e977147c7b3.tar.gz |
Some minor corrections:
* Expose functions for setting the "skip file" dev/ino information
* Expose functions for setting/querying the block size on reads
* Correctly propagate errors out of archive_read_close/archive_write_close
* Update manpage with information about new functions
Diffstat (limited to 'lib/libarchive/archive_write.c')
-rw-r--r-- | lib/libarchive/archive_write.c | 54 |
1 files changed, 47 insertions, 7 deletions
diff --git a/lib/libarchive/archive_write.c b/lib/libarchive/archive_write.c index 3a999ca..446bb69 100644 --- a/lib/libarchive/archive_write.c +++ b/lib/libarchive/archive_write.c @@ -88,7 +88,6 @@ archive_write_new(void) return (a); } - /* * Set the block size. Returns 0 if successful. */ @@ -100,6 +99,15 @@ archive_write_set_bytes_per_block(struct archive *a, int bytes_per_block) return (ARCHIVE_OK); } +/* + * Get the current block size. -1 if it has never been set. + */ +int +archive_write_get_bytes_per_block(struct archive *a) +{ + __archive_check_magic(a, ARCHIVE_WRITE_MAGIC, ARCHIVE_STATE_ANY, "archive_write_get_bytes_per_block"); + return (a->bytes_per_block); +} /* * Set the size for the last block. @@ -113,6 +121,30 @@ archive_write_set_bytes_in_last_block(struct archive *a, int bytes) return (ARCHIVE_OK); } +/* + * Return the value set above. -1 indicates it has not been set. + */ +int +archive_write_get_bytes_in_last_block(struct archive *a) +{ + __archive_check_magic(a, ARCHIVE_WRITE_MAGIC, ARCHIVE_STATE_ANY, "archive_write_get_bytes_in_last_block"); + return (a->bytes_in_last_block); +} + + +/* + * dev/ino of a file to be rejected. Used to prevent adding + * an archive to itself recursively. + */ +int +archive_write_set_skip_file(struct archive *a, dev_t d, ino_t i) +{ + __archive_check_magic(a, ARCHIVE_WRITE_MAGIC, ARCHIVE_STATE_ANY, "archive_write_set_skip_file"); + a->skip_file_dev = d; + a->skip_file_ino = i; + return (ARCHIVE_OK); +} + /* * Open the archive using the current settings. @@ -149,22 +181,30 @@ archive_write_open(struct archive *a, void *client_data, int archive_write_close(struct archive *a) { + int r = ARCHIVE_OK, r1 = ARCHIVE_OK; + __archive_check_magic(a, ARCHIVE_WRITE_MAGIC, ARCHIVE_STATE_ANY, "archive_write_close"); /* Finish the last entry. */ if (a->state & ARCHIVE_STATE_DATA) - ((a->format_finish_entry)(a)); + r = ((a->format_finish_entry)(a)); /* Finish off the archive. */ - if (a->format_finish != NULL) - (a->format_finish)(a); + if (a->format_finish != NULL) { + r1 = (a->format_finish)(a); + if (r1 < r) + r = r1; + } /* Finish the compression and close the stream. */ - if (a->compression_finish != NULL) - (a->compression_finish)(a); + if (a->compression_finish != NULL) { + r1 = (a->compression_finish)(a); + if (r1 < r) + r = r1; + } a->state = ARCHIVE_STATE_CLOSED; - return (ARCHIVE_OK); + return (r); } /* |