From: Kirill Okhotnikov Date: Mon, 1 Jun 2015 08:31:12 +0000 (+0200) Subject: archive_write_set_format_filter_by_ext: man pages updated. X-Git-Tag: v3.1.900a~94^2^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8b9ee99cb01808f766ff6a7859426c0674775a2a;p=thirdparty%2Flibarchive.git archive_write_set_format_filter_by_ext: man pages updated. --- diff --git a/libarchive/archive_write.3 b/libarchive/archive_write.3 index 6f4cff83b..a56f2dba5 100644 --- a/libarchive/archive_write.3 +++ b/libarchive/archive_write.3 @@ -186,8 +186,13 @@ write_archive(const char *outname, const char **filename) a = archive_write_new(); mydata->name = outname; - archive_write_add_filter_gzip(a); - archive_write_set_format_ustar(a); + /* Set archive format and filter according to output file extension. + * If it fails, set default format. Platform depended function. + * See supported formats in archive_write_set_format_filter_by_ext.c */ + if ( archive_write_set_format_filter_by_ext(a, outname) != ARCHIVE_OK ) { + archive_write_add_filter_gzip(a); + archive_write_set_format_ustar(a); + } archive_write_open(a, mydata, myopen, mywrite, myclose); while (*filename) { stat(*filename, &st); diff --git a/libarchive/archive_write_format.3 b/libarchive/archive_write_format.3 index 39d300646..4bd116340 100644 --- a/libarchive/archive_write_format.3 +++ b/libarchive/archive_write_format.3 @@ -34,7 +34,9 @@ .Nm archive_write_set_format_raw , .Nm archive_write_set_format_shar , .Nm archive_write_set_format_shar_dump , -.Nm archive_write_set_format_ustar +.Nm archive_write_set_format_ustar , +.Nm archive_write_set_format_filter_by_ext , +.Nm archive_write_set_format_filter_by_ext_def .Nd functions for creating archives .Sh LIBRARY Streaming Archive Library (libarchive, -larchive) @@ -54,6 +56,10 @@ Streaming Archive Library (libarchive, -larchive) .Fn archive_write_set_format_shar_dump "struct archive *" .Ft int .Fn archive_write_set_format_ustar "struct archive *" +.Ft int +.Fn archive_write_set_format_filter_by_ext "struct archive *" "const char *" +.Ft int +.Fn archive_write_set_format_filter_by_ext_def "struct archive *" "const char *" "const char *" .Sh DESCRIPTION These functions set the format that will be used for the archive. .Pp @@ -79,6 +85,14 @@ filenames, linknames, uids, sizes, etc. is the library default; this is the same as pax format, but suppresses the pax extended header for most normal files. In most cases, this will result in ordinary ustar archives. +.Bl -tag -width indent +.It Xo +.Fn archive_write_set_format_filter_by_ext , +.Fn archive_write_set_format_filter_by_ext_def +.Xc +Format and filter for archive can be set automatically, based on output file name extension. +The functions are platform dependent. +Supported extensions: .7z, .zip, .jar, .cpio, .iso, .a, .ar, .tar, .tgz, .tar.gz, .tar.bz2, .tar.xz .\" .Sh RETURN VALUES These functions return