diff options
author | Brad King <brad.king@kitware.com> | 2014-04-17 09:10:56 -0400 |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2014-04-17 09:10:56 -0400 |
commit | c14010e4ea65d25e0b511ac7fd1d767c2b0b7d34 (patch) | |
tree | 5b97de1da213cf6ef292f6d61a8aea1a727d3c00 /Source/cmArchiveWrite.cxx | |
parent | ef10fc47ae07a61ff560c88f768113ed157757f2 (diff) | |
parent | b508de59e852a5068f3b9838e2be8a485235b934 (diff) | |
download | cmake-c14010e4ea65d25e0b511ac7fd1d767c2b0b7d34.tar.gz |
Merge topic 'archive-null-error'
b508de59 cmArchiveWrite: Handle NULL error string (#14882)
Diffstat (limited to 'Source/cmArchiveWrite.cxx')
-rw-r--r-- | Source/cmArchiveWrite.cxx | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/Source/cmArchiveWrite.cxx b/Source/cmArchiveWrite.cxx index d5dcd6ab3e..58f7573c29 100644 --- a/Source/cmArchiveWrite.cxx +++ b/Source/cmArchiveWrite.cxx @@ -18,6 +18,13 @@ #include <cm_libarchive.h> //---------------------------------------------------------------------------- +static std::string cm_archive_error_string(struct archive* a) +{ + const char* e = archive_error_string(a); + return e? e : "unknown error"; +} + +//---------------------------------------------------------------------------- class cmArchiveWrite::Entry { struct archive_entry* Object; @@ -60,7 +67,7 @@ cmArchiveWrite::cmArchiveWrite(std::ostream& os, Compress c, Type t): if(archive_write_set_compression_none(this->Archive) != ARCHIVE_OK) { this->Error = "archive_write_set_compression_none: "; - this->Error += archive_error_string(this->Archive); + this->Error += cm_archive_error_string(this->Archive); return; } break; @@ -68,7 +75,7 @@ cmArchiveWrite::cmArchiveWrite(std::ostream& os, Compress c, Type t): if(archive_write_set_compression_compress(this->Archive) != ARCHIVE_OK) { this->Error = "archive_write_set_compression_compress: "; - this->Error += archive_error_string(this->Archive); + this->Error += cm_archive_error_string(this->Archive); return; } break; @@ -76,7 +83,7 @@ cmArchiveWrite::cmArchiveWrite(std::ostream& os, Compress c, Type t): if(archive_write_set_compression_gzip(this->Archive) != ARCHIVE_OK) { this->Error = "archive_write_set_compression_gzip: "; - this->Error += archive_error_string(this->Archive); + this->Error += cm_archive_error_string(this->Archive); return; } break; @@ -84,7 +91,7 @@ cmArchiveWrite::cmArchiveWrite(std::ostream& os, Compress c, Type t): if(archive_write_set_compression_bzip2(this->Archive) != ARCHIVE_OK) { this->Error = "archive_write_set_compression_bzip2: "; - this->Error += archive_error_string(this->Archive); + this->Error += cm_archive_error_string(this->Archive); return; } break; @@ -92,7 +99,7 @@ cmArchiveWrite::cmArchiveWrite(std::ostream& os, Compress c, Type t): if(archive_write_set_compression_lzma(this->Archive) != ARCHIVE_OK) { this->Error = "archive_write_set_compression_lzma: "; - this->Error += archive_error_string(this->Archive); + this->Error += cm_archive_error_string(this->Archive); return; } break; @@ -100,7 +107,7 @@ cmArchiveWrite::cmArchiveWrite(std::ostream& os, Compress c, Type t): if(archive_write_set_compression_xz(this->Archive) != ARCHIVE_OK) { this->Error = "archive_write_set_compression_xz: "; - this->Error += archive_error_string(this->Archive); + this->Error += cm_archive_error_string(this->Archive); return; } break; @@ -109,7 +116,7 @@ cmArchiveWrite::cmArchiveWrite(std::ostream& os, Compress c, Type t): 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); + this->Error += cm_archive_error_string(this->Archive); return;; } #endif @@ -119,7 +126,7 @@ cmArchiveWrite::cmArchiveWrite(std::ostream& os, Compress c, Type t): if(archive_write_set_format_zip(this->Archive) != ARCHIVE_OK) { this->Error = "archive_write_set_format_zip: "; - this->Error += archive_error_string(this->Archive); + this->Error += cm_archive_error_string(this->Archive); return; } break; @@ -127,7 +134,7 @@ cmArchiveWrite::cmArchiveWrite(std::ostream& os, Compress c, Type t): 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); + this->Error += cm_archive_error_string(this->Archive); return; } break; @@ -137,7 +144,7 @@ cmArchiveWrite::cmArchiveWrite(std::ostream& os, Compress c, Type t): if (archive_write_set_bytes_in_last_block(this->Archive, 1)) { this->Error = "archive_write_set_bytes_in_last_block: "; - this->Error += archive_error_string(this->Archive); + this->Error += cm_archive_error_string(this->Archive); return; } @@ -147,7 +154,7 @@ cmArchiveWrite::cmArchiveWrite(std::ostream& os, Compress c, Type t): 0) != ARCHIVE_OK) { this->Error = "archive_write_open: "; - this->Error += archive_error_string(this->Archive); + this->Error += cm_archive_error_string(this->Archive); return; } } @@ -235,7 +242,7 @@ bool cmArchiveWrite::AddFile(const char* file, if(archive_read_disk_entry_from_file(this->Disk, e, -1, 0) != ARCHIVE_OK) { this->Error = "archive_read_disk_entry_from_file: "; - this->Error += archive_error_string(this->Disk); + this->Error += cm_archive_error_string(this->Disk); return false; } // Clear acl and xattr fields not useful for distribution. @@ -245,7 +252,7 @@ bool cmArchiveWrite::AddFile(const char* file, if(archive_write_header(this->Archive, e) != ARCHIVE_OK) { this->Error = "archive_write_header: "; - this->Error += archive_error_string(this->Archive); + this->Error += cm_archive_error_string(this->Archive); return false; } @@ -292,7 +299,7 @@ bool cmArchiveWrite::AddData(const char* file, size_t size) if(archive_write_data(this->Archive, buffer, nnext) != nnext_s) { this->Error = "archive_write_data: "; - this->Error += archive_error_string(this->Archive); + this->Error += cm_archive_error_string(this->Archive); return false; } nleft -= nnext; |