summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorKyle Edwards <kyle.edwards@kitware.com>2019-03-19 17:37:48 (GMT)
committerKitware Robot <kwrobot@kitware.com>2019-03-19 17:37:59 (GMT)
commitf1e53266e9ce7e8a9568bde23f865136be958887 (patch)
treebb036d8514e430f4d6df415c73b7664dbcd5aab9 /Source
parentd2101e944a03056dc2180dd790ba85175e04d653 (diff)
parent8634576dcb03087fc507b8012a47f1ecc852f65f (diff)
downloadCMake-f1e53266e9ce7e8a9568bde23f865136be958887.zip
CMake-f1e53266e9ce7e8a9568bde23f865136be958887.tar.gz
CMake-f1e53266e9ce7e8a9568bde23f865136be958887.tar.bz2
Merge topic 'improve-tar-command'
8634576dcb cmake: Don't interrupt archive creation if unable to read a file. c7c6a4a2cc Help: Update 'tar' documentation with supported arguments 7c47fd8cd1 cmake: tar: Display warning when no files provided during archive creation Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !3080
Diffstat (limited to 'Source')
-rw-r--r--Source/cmArchiveWrite.cxx11
-rw-r--r--Source/cmSystemTools.cxx10
-rw-r--r--Source/cmcmd.cxx4
3 files changed, 13 insertions, 12 deletions
diff --git a/Source/cmArchiveWrite.cxx b/Source/cmArchiveWrite.cxx
index 23be603..177ba02 100644
--- a/Source/cmArchiveWrite.cxx
+++ b/Source/cmArchiveWrite.cxx
@@ -179,12 +179,10 @@ cmArchiveWrite::~cmArchiveWrite()
bool cmArchiveWrite::Add(std::string path, size_t skip, const char* prefix,
bool recursive)
{
- if (this->Okay()) {
- if (!path.empty() && path.back() == '/') {
- path.erase(path.size() - 1);
- }
- this->AddPath(path.c_str(), skip, prefix, recursive);
+ if (!path.empty() && path.back() == '/') {
+ path.erase(path.size() - 1);
}
+ this->AddPath(path.c_str(), skip, prefix, recursive);
return this->Okay();
}
@@ -220,6 +218,7 @@ bool cmArchiveWrite::AddPath(const char* path, size_t skip, const char* prefix,
bool cmArchiveWrite::AddFile(const char* file, size_t skip, const char* prefix)
{
+ this->Error = "";
// Skip the file if we have no name for it. This may happen on a
// top-level directory, which does not need to be included anyway.
if (skip >= strlen(file)) {
@@ -241,7 +240,7 @@ bool cmArchiveWrite::AddFile(const char* file, size_t skip, const char* prefix)
cm_archive_entry_copy_pathname(e, dest);
if (archive_read_disk_entry_from_file(this->Disk, e, -1, nullptr) !=
ARCHIVE_OK) {
- this->Error = "archive_read_disk_entry_from_file '";
+ this->Error = "Unable to read from file '";
this->Error += file;
this->Error += "': ";
this->Error += cm_archive_error_string(this->Disk);
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index d762106..41f8cf4 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -1658,20 +1658,18 @@ bool cmSystemTools::CreateTar(const char* outFileName,
a.SetMTime(mtime);
a.SetVerbose(verbose);
+ bool tarCreatedSuccessfully = true;
for (auto path : files) {
if (cmSystemTools::FileIsFullPath(path)) {
// Get the relative path to the file.
path = cmSystemTools::RelativePath(cwd, path);
}
if (!a.Add(path)) {
- break;
+ cmSystemTools::Error(a.GetError());
+ tarCreatedSuccessfully = false;
}
}
- if (!a) {
- cmSystemTools::Error(a.GetError());
- return false;
- }
- return true;
+ return tarCreatedSuccessfully;
#else
(void)outFileName;
(void)files;
diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx
index f996a3e..0828a16 100644
--- a/Source/cmcmd.cxx
+++ b/Source/cmcmd.cxx
@@ -1114,6 +1114,10 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
return 1;
}
} else if (flags.find_first_of('c') != std::string::npos) {
+ if (files.empty()) {
+ cmSystemTools::Message("tar: No files or directories specified",
+ "Warning");
+ }
if (!cmSystemTools::CreateTar(outFile.c_str(), files, compress,
verbose, mtime, format)) {
cmSystemTools::Error("Problem creating tar: " + outFile);