summaryrefslogtreecommitdiffstats
path: root/libarchive/archive_write.3
diff options
context:
space:
mode:
authorLibArchive Upstream <libarchive-discuss@googlegroups.com>2015-10-21 08:47:34 (GMT)
committerBrad King <brad.king@kitware.com>2015-10-21 13:37:00 (GMT)
commit1a8c7bc2c649781d1163c1966245a45e0fb829ba (patch)
tree9be1fb64019a5ef371a2f4136831e275546dc5a6 /libarchive/archive_write.3
parent37f225b72c8e4c440025a98f68eda9914f7ba5f7 (diff)
downloadCMake-1a8c7bc2c649781d1163c1966245a45e0fb829ba.zip
CMake-1a8c7bc2c649781d1163c1966245a45e0fb829ba.tar.gz
CMake-1a8c7bc2c649781d1163c1966245a45e0fb829ba.tar.bz2
libarchive 3.1.2-601-g3bfe5f1 (reduced)
Extract upstream libarchive using the following shell code. url=git://github.com/libarchive/libarchive.git && v=3.1.2-601-g3bfe5f1 && r=3bfe5f1 && paths=" CMakeLists.txt COPYING CTestConfig.cmake build/cmake build/pkgconfig build/utils build/version libarchive/*.* " && mkdir libarchive-$v-g$r-reduced && git clone $url libarchive-git && date=$(cd libarchive-git && git log -n 1 --format='%cd' $r) && (cd libarchive-git && git archive --format=tar $r -- $paths) | (cd libarchive-$v-g$r-reduced && tar xv) && fromdos libarchive-$v-g$r-reduced/build/cmake/Find*.cmake && echo "g$r date: $date"
Diffstat (limited to 'libarchive/archive_write.3')
-rw-r--r--libarchive/archive_write.315
1 files changed, 10 insertions, 5 deletions
diff --git a/libarchive/archive_write.3 b/libarchive/archive_write.3
index 228bc2c..376d71d 100644
--- a/libarchive/archive_write.3
+++ b/libarchive/archive_write.3
@@ -155,7 +155,7 @@ myopen(struct archive *a, void *client_data)
return (ARCHIVE_FATAL);
}
-ssize_t
+la_ssize_t
mywrite(struct archive *a, void *client_data, const void *buff, size_t n)
{
struct mydata *mydata = client_data;
@@ -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);
@@ -197,7 +202,7 @@ write_archive(const char *outname, const char **filename)
archive_write_header(a, entry);
if ((fd = open(*filename, O_RDONLY)) != -1) {
len = read(fd, buff, sizeof(buff));
- while ( len > 0 ) {
+ while (len > 0) {
archive_write_data(a, buff, len);
len = read(fd, buff, sizeof(buff));
}
@@ -213,7 +218,7 @@ int main(int argc, const char **argv)
{
const char *outname;
argv++;
- outname = argv++;
+ outname = *argv++;
write_archive(outname, argv);
return 0;
}