summaryrefslogtreecommitdiffstats
path: root/Source/cmArchiveWrite.cxx
diff options
context:
space:
mode:
authorNils Gladitz <nilsgladitz@gmail.com>2015-04-07 10:36:52 (GMT)
committerBrad King <brad.king@kitware.com>2015-04-10 12:32:31 (GMT)
commitd2cc580704fa4e608eae104ce5be211a229b2d64 (patch)
treefd9459775349e127095719de4252c790b781fd02 /Source/cmArchiveWrite.cxx
parent1264c5b2c485416128466510c42ab40a03eb0ca3 (diff)
downloadCMake-d2cc580704fa4e608eae104ce5be211a229b2d64.zip
CMake-d2cc580704fa4e608eae104ce5be211a229b2d64.tar.gz
CMake-d2cc580704fa4e608eae104ce5be211a229b2d64.tar.bz2
cmake: Teach "-E tar" command a "--format=" option
Allows specifying a libarchive defined archive format currently restricted to 7zip, gnutar, pax, paxr and zip. The default is "paxr" (pax restricted).
Diffstat (limited to 'Source/cmArchiveWrite.cxx')
-rw-r--r--Source/cmArchiveWrite.cxx44
1 files changed, 13 insertions, 31 deletions
diff --git a/Source/cmArchiveWrite.cxx b/Source/cmArchiveWrite.cxx
index cf2fe82..72818f5 100644
--- a/Source/cmArchiveWrite.cxx
+++ b/Source/cmArchiveWrite.cxx
@@ -79,11 +79,12 @@ struct cmArchiveWrite::Callback
};
//----------------------------------------------------------------------------
-cmArchiveWrite::cmArchiveWrite(std::ostream& os, Compress c, Type t):
- Stream(os),
- Archive(archive_write_new()),
- Disk(archive_read_disk_new()),
- Verbose(false)
+cmArchiveWrite::cmArchiveWrite(
+ std::ostream& os, Compress c, std::string const& format):
+ Stream(os),
+ Archive(archive_write_new()),
+ Disk(archive_read_disk_new()),
+ Verbose(false)
{
switch (c)
{
@@ -141,35 +142,16 @@ cmArchiveWrite::cmArchiveWrite(std::ostream& os, Compress c, Type t):
{
this->Error = "archive_read_disk_set_standard_lookup: ";
this->Error += cm_archive_error_string(this->Archive);
- return;;
+ return;
}
#endif
- switch (t)
+
+ if(archive_write_set_format_by_name(this->Archive, format.c_str())
+ != ARCHIVE_OK)
{
- case TypeZIP:
- if(archive_write_set_format_zip(this->Archive) != ARCHIVE_OK)
- {
- this->Error = "archive_write_set_format_zip: ";
- this->Error += cm_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 += cm_archive_error_string(this->Archive);
- return;
- }
- break;
- case Type7Zip:
- if(archive_write_set_format_7zip(this->Archive) != ARCHIVE_OK)
- {
- this->Error = "archive_write_set_format_7zip: ";
- this->Error += cm_archive_error_string(this->Archive);
- return;
- }
- break;
+ this->Error = "archive_write_set_format_by_name: ";
+ this->Error += cm_archive_error_string(this->Archive);
+ return;
}
// do not pad the last block!!