diff options
Diffstat (limited to 'usr.bin/tar/write.c')
-rw-r--r-- | usr.bin/tar/write.c | 43 |
1 files changed, 20 insertions, 23 deletions
diff --git a/usr.bin/tar/write.c b/usr.bin/tar/write.c index 6f89286..efc94de 100644 --- a/usr.bin/tar/write.c +++ b/usr.bin/tar/write.c @@ -189,6 +189,14 @@ tar_mode_c(struct bsdtar *bsdtar) archive_write_set_compression_bzip2(a); break; #endif +#ifdef HAVE_LIBLZMA + case 'J': + archive_write_set_compression_xz(a); + break; + case OPTION_LZMA: + archive_write_set_compression_lzma(a); + break; +#endif #ifdef HAVE_LIBZ case 'z': archive_write_set_compression_gzip(a); @@ -204,16 +212,10 @@ tar_mode_c(struct bsdtar *bsdtar) } } - r = archive_write_open_file(a, bsdtar->filename); - if (r != ARCHIVE_OK) + if (ARCHIVE_OK != archive_write_set_options(a, bsdtar->option_options)) + bsdtar_errc(bsdtar, 1, 0, archive_error_string(a)); + if (ARCHIVE_OK != archive_write_open_file(a, bsdtar->filename)) bsdtar_errc(bsdtar, 1, 0, archive_error_string(a)); - - if (bsdtar->option_format_options != NULL) { - r = archive_write_set_options(a, bsdtar->option_format_options); - if (r != ARCHIVE_OK) - bsdtar_errc(bsdtar, 1, 0, archive_error_string(a)); - } - write_archive(a, bsdtar); } @@ -299,12 +301,10 @@ tar_mode_r(struct bsdtar *bsdtar) archive_write_set_format(a, format); } lseek(bsdtar->fd, end_offset, SEEK_SET); /* XXX check return val XXX */ - archive_write_open_fd(a, bsdtar->fd); /* XXX check return val XXX */ - if (bsdtar->option_format_options != NULL) { - r = archive_write_set_options(a, bsdtar->option_format_options); - if (r != ARCHIVE_OK) - bsdtar_errc(bsdtar, 1, 0, archive_error_string(a)); - } + if (ARCHIVE_OK != archive_write_set_options(a, bsdtar->option_options)) + bsdtar_errc(bsdtar, 1, 0, archive_error_string(a)); + if (ARCHIVE_OK != archive_write_open_fd(a, bsdtar->fd)) + bsdtar_errc(bsdtar, 1, 0, archive_error_string(a)); write_archive(a, bsdtar); /* XXX check return val XXX */ @@ -321,7 +321,6 @@ tar_mode_u(struct bsdtar *bsdtar) int format; struct archive_dir_entry *p; struct archive_dir archive_dir; - int r; bsdtar->archive_dir = &archive_dir; memset(&archive_dir, 0, sizeof(archive_dir)); @@ -385,12 +384,10 @@ tar_mode_u(struct bsdtar *bsdtar) archive_write_set_bytes_per_block(a, DEFAULT_BYTES_PER_BLOCK); lseek(bsdtar->fd, end_offset, SEEK_SET); ftruncate(bsdtar->fd, end_offset); - archive_write_open_fd(a, bsdtar->fd); - if (bsdtar->option_format_options != NULL) { - r = archive_write_set_options(a, bsdtar->option_format_options); - if (r != ARCHIVE_OK) - bsdtar_errc(bsdtar, 1, 0, archive_error_string(a)); - } + if (ARCHIVE_OK != archive_write_set_options(a, bsdtar->option_options)) + bsdtar_errc(bsdtar, 1, 0, archive_error_string(a)); + if (ARCHIVE_OK != archive_write_open_fd(a, bsdtar->fd)) + bsdtar_errc(bsdtar, 1, 0, archive_error_string(a)); write_archive(a, bsdtar); @@ -457,7 +454,7 @@ write_archive(struct archive *a, struct bsdtar *bsdtar) arg + 1) != 0) break; } else -#ifdef _WIN32 +#if defined(_WIN32) && !defined(__CYGWIN__) write_hierarchy_win(bsdtar, a, arg, write_hierarchy); #else |