summaryrefslogtreecommitdiffstats
path: root/Source/cmArchiveWrite.cxx
diff options
context:
space:
mode:
authorEric NOULARD <eric.noulard@gmail.com>2010-08-13 15:49:47 (GMT)
committerEric NOULARD <eric.noulard@gmail.com>2010-08-13 15:49:47 (GMT)
commitb50c15915ac5cca79e00bf438dacd074fe531978 (patch)
tree2df00db421f95453c309703cd06244ecd166163b /Source/cmArchiveWrite.cxx
parent4663356079da1c578ab0f7762b4c9d87327b80c3 (diff)
downloadCMake-b50c15915ac5cca79e00bf438dacd074fe531978.zip
CMake-b50c15915ac5cca79e00bf438dacd074fe531978.tar.gz
CMake-b50c15915ac5cca79e00bf438dacd074fe531978.tar.bz2
Add ZIP archive format and LZMA compress support to libarchive-wrapper
This will be needed to use cmArchiveWrire in cmCPackArchiveGenerator with the same feature set as before. Note that adding zip support to libarchive-wrapper would also makes it easy to add a new -E zip command to cmake commands.
Diffstat (limited to 'Source/cmArchiveWrite.cxx')
-rw-r--r--Source/cmArchiveWrite.cxx44
1 files changed, 40 insertions, 4 deletions
diff --git a/Source/cmArchiveWrite.cxx b/Source/cmArchiveWrite.cxx
index 94c97e6..bea9586 100644
--- a/Source/cmArchiveWrite.cxx
+++ b/Source/cmArchiveWrite.cxx
@@ -47,7 +47,7 @@ struct cmArchiveWrite::Callback
};
//----------------------------------------------------------------------------
-cmArchiveWrite::cmArchiveWrite(std::ostream& os, Compress c):
+cmArchiveWrite::cmArchiveWrite(std::ostream& os, Compress c, Type t):
Stream(os),
Archive(archive_write_new()),
Disk(archive_read_disk_new()),
@@ -79,11 +79,47 @@ cmArchiveWrite::cmArchiveWrite(std::ostream& os, Compress c):
return;
}
break;
+ case CompressLZMA:
+ if(archive_write_set_compression_lzma(this->Archive) != ARCHIVE_OK)
+ {
+ this->Error = "archive_write_set_compression_lzma: ";
+ this->Error += archive_error_string(this->Archive);
+ return;
+ }
+ break;
};
- archive_read_disk_set_standard_lookup(this->Disk);
- if(archive_write_set_format_pax_restricted(this->Archive) != ARCHIVE_OK)
+#if !defined(_WIN32) || defined(__CYGWIN__)
+ if (archive_read_disk_set_standard_lookup(this->Disk) != ARCHIVE_OK)
+ {
+ this->Error = "archive_read_disk_set_standard_lookup: ";
+ this->Error += archive_error_string(this->Archive);
+ return;;
+ }
+#endif
+ switch (t)
+ {
+ case TypeZIP:
+ if(archive_write_set_format_zip(this->Archive) != ARCHIVE_OK)
+ {
+ this->Error = "archive_write_set_format_zip: ";
+ this->Error += archive_error_string(this->Archive);
+ return;
+ }
+ break;
+ case TypeTAR:
+ if(archive_write_set_format_pax_restricted(this->Archive) != ARCHIVE_OK)
+ {
+ this->Error = "archive_write_set_format_pax_restricted: ";
+ this->Error += archive_error_string(this->Archive);
+ return;
+ }
+ break;
+ }
+
+ // do not pad the last block!!
+ if (archive_write_set_bytes_in_last_block(this->Archive, 1))
{
- this->Error = "archive_write_set_format_pax_restricted: ";
+ this->Error = "archive_write_set_bytes_in_last_block: ";
this->Error += archive_error_string(this->Archive);
return;
}