summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Boeckel <ben.boeckel@kitware.com>2019-04-04 18:03:21 (GMT)
committerBen Boeckel <ben.boeckel@kitware.com>2020-03-31 15:08:32 (GMT)
commitb9c17de023ea50e7be358519141971aa136858ca (patch)
tree348ecb16aa8ac6193f0a837b3255d4c933b77c68
parent206a65c3b8156acc0677a9adb2ab149021f25c20 (diff)
downloadCMake-b9c17de023ea50e7be358519141971aa136858ca.zip
CMake-b9c17de023ea50e7be358519141971aa136858ca.tar.gz
CMake-b9c17de023ea50e7be358519141971aa136858ca.tar.bz2
cmArchiveWrite: split out opening the file
This allows options to be set before the "header" phase of libarchive's API.
-rw-r--r--Source/CPack/cmCPackArchiveGenerator.cxx7
-rw-r--r--Source/CPack/cmCPackDebGenerator.cxx3
-rw-r--r--Source/cmArchiveWrite.cxx6
-rw-r--r--Source/cmArchiveWrite.h2
-rw-r--r--Source/cmSystemTools.cxx1
5 files changed, 18 insertions, 1 deletions
diff --git a/Source/CPack/cmCPackArchiveGenerator.cxx b/Source/CPack/cmCPackArchiveGenerator.cxx
index 43f2946..f0a6965 100644
--- a/Source/CPack/cmCPackArchiveGenerator.cxx
+++ b/Source/CPack/cmCPackArchiveGenerator.cxx
@@ -154,6 +154,13 @@ int cmCPackArchiveGenerator::addOneComponentToArchive(
} \
cmArchiveWrite archive(gf, this->Compress, this->ArchiveFormat); \
do { \
+ if (!archive.Open()) { \
+ cmCPackLogger(cmCPackLog::LOG_ERROR, \
+ "Problem to open archive <" \
+ << (filename) << ">, ERROR = " << (archive).GetError() \
+ << std::endl); \
+ return 0; \
+ } \
if (!(archive)) { \
cmCPackLogger(cmCPackLog::LOG_ERROR, \
"Problem to create archive <" \
diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx
index 5b7d8fb..c30a57a 100644
--- a/Source/CPack/cmCPackDebGenerator.cxx
+++ b/Source/CPack/cmCPackDebGenerator.cxx
@@ -173,6 +173,7 @@ bool DebGenerator::generateDataTar() const
}
cmArchiveWrite data_tar(fileStream_data_tar, TarCompressionType,
DebianArchiveType);
+ data_tar.Open();
// uid/gid should be the one of the root user, and this root user has
// always uid/gid equal to 0.
@@ -291,6 +292,7 @@ bool DebGenerator::generateControlTar(std::string const& md5Filename) const
}
cmArchiveWrite control_tar(fileStream_control_tar,
cmArchiveWrite::CompressGZip, DebianArchiveType);
+ control_tar.Open();
// sets permissions and uid/gid for the files
control_tar.SetUIDAndGID(0u, 0u);
@@ -410,6 +412,7 @@ bool DebGenerator::generateDeb() const
cmGeneratedFileStream debStream;
debStream.Open(outputPath, false, true);
cmArchiveWrite deb(debStream, cmArchiveWrite::CompressNone, "arbsd");
+ deb.Open();
// uid/gid should be the one of the root user, and this root user has
// always uid/gid equal to 0.
diff --git a/Source/cmArchiveWrite.cxx b/Source/cmArchiveWrite.cxx
index d29b2ac..07136da 100644
--- a/Source/cmArchiveWrite.cxx
+++ b/Source/cmArchiveWrite.cxx
@@ -170,15 +170,19 @@ cmArchiveWrite::cmArchiveWrite(std::ostream& os, Compress c,
cm_archive_error_string(this->Archive));
return;
}
+}
+bool cmArchiveWrite::Open()
+{
if (archive_write_open(
this->Archive, this, nullptr,
reinterpret_cast<archive_write_callback*>(&Callback::Write),
nullptr) != ARCHIVE_OK) {
this->Error =
cmStrCat("archive_write_open: ", cm_archive_error_string(this->Archive));
- return;
+ return false;
}
+ return true;
}
cmArchiveWrite::~cmArchiveWrite()
diff --git a/Source/cmArchiveWrite.h b/Source/cmArchiveWrite.h
index e791761..286d20b 100644
--- a/Source/cmArchiveWrite.h
+++ b/Source/cmArchiveWrite.h
@@ -62,6 +62,8 @@ public:
cmArchiveWrite(const cmArchiveWrite&) = delete;
cmArchiveWrite& operator=(const cmArchiveWrite&) = delete;
+ bool Open();
+
/**
* Add a path (file or directory) to the archive. Directories are
* added recursively. The "path" must be readable on disk, either
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index d8cd705..589dcc0 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -1312,6 +1312,7 @@ bool cmSystemTools::CreateTar(const std::string& outFileName,
cmArchiveWrite a(fout, compress, format.empty() ? "paxr" : format);
+ a.Open();
a.SetMTime(mtime);
a.SetVerbose(verbose);
bool tarCreatedSuccessfully = true;