summaryrefslogtreecommitdiffstats
path: root/Source/CPack
diff options
context:
space:
mode:
authorCraig Scott <craig.scott@crascit.com>2018-03-04 06:27:09 (GMT)
committerCraig Scott <craig.scott@crascit.com>2018-03-08 09:07:14 (GMT)
commite60e4dfc88252aaec53f0d832508d41dff6165fd (patch)
tree5903e9e8f2eb57780d47a21d83f282f9cee11741 /Source/CPack
parente654622aee22655c418a9c663fad79243ca0c819 (diff)
downloadCMake-e60e4dfc88252aaec53f0d832508d41dff6165fd.zip
CMake-e60e4dfc88252aaec53f0d832508d41dff6165fd.tar.gz
CMake-e60e4dfc88252aaec53f0d832508d41dff6165fd.tar.bz2
cmWorkingDirectory: Check success of current dir changes
Diffstat (limited to 'Source/CPack')
-rw-r--r--Source/CPack/cmCPackArchiveGenerator.cxx16
-rw-r--r--Source/CPack/cmCPackGenerator.cxx8
2 files changed, 24 insertions, 0 deletions
diff --git a/Source/CPack/cmCPackArchiveGenerator.cxx b/Source/CPack/cmCPackArchiveGenerator.cxx
index 9ff547a..00fbdab 100644
--- a/Source/CPack/cmCPackArchiveGenerator.cxx
+++ b/Source/CPack/cmCPackArchiveGenerator.cxx
@@ -9,6 +9,7 @@
#include "cmSystemTools.h"
#include "cmWorkingDirectory.h"
+#include <cstring>
#include <ostream>
#include <utility>
#include <vector>
@@ -51,6 +52,7 @@ int cmCPackArchiveGenerator::InitializeInternal()
this->SetOptionIfNotSet("CPACK_INCLUDE_TOPLEVEL_DIRECTORY", "1");
return this->Superclass::InitializeInternal();
}
+
int cmCPackArchiveGenerator::addOneComponentToArchive(
cmArchiveWrite& archive, cmCPackComponent* component)
{
@@ -61,6 +63,13 @@ int cmCPackArchiveGenerator::addOneComponentToArchive(
localToplevel += "/" + component->Name;
// Change to local toplevel
cmWorkingDirectory workdir(localToplevel);
+ if (workdir.Failed()) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Failed to change working directory to "
+ << localToplevel << " : "
+ << std::strerror(workdir.GetLastResult()) << std::endl);
+ return 0;
+ }
std::string filePrefix;
if (this->IsOn("CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY")) {
filePrefix = this->GetOption("CPACK_PACKAGE_FILE_NAME");
@@ -237,6 +246,13 @@ int cmCPackArchiveGenerator::PackageFiles()
// CASE 3 : NON COMPONENT package.
DECLARE_AND_OPEN_ARCHIVE(packageFileNames[0], archive);
cmWorkingDirectory workdir(toplevel);
+ if (workdir.Failed()) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Failed to change working directory to "
+ << toplevel << " : "
+ << std::strerror(workdir.GetLastResult()) << std::endl);
+ return 0;
+ }
for (std::string const& file : files) {
// Get the relative path to the file
std::string rp = cmSystemTools::RelativePath(toplevel, file);
diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx
index d838b30..d41a9e5 100644
--- a/Source/CPack/cmCPackGenerator.cxx
+++ b/Source/CPack/cmCPackGenerator.cxx
@@ -6,6 +6,7 @@
#include "cmsys/Glob.hxx"
#include "cmsys/RegularExpression.hxx"
#include <algorithm>
+#include <cstring>
#include <memory> // IWYU pragma: keep
#include <utility>
@@ -404,6 +405,13 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories(
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Change dir to: " << goToDir
<< std::endl);
cmWorkingDirectory workdir(goToDir);
+ if (workdir.Failed()) {
+ cmCPackLogger(
+ cmCPackLog::LOG_ERROR, "Failed to change working directory to "
+ << goToDir << " : " << std::strerror(workdir.GetLastResult())
+ << std::endl);
+ return 0;
+ }
for (auto const& symlinked : symlinkedFiles) {
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Will create a symlink: "
<< symlinked.second << "--> " << symlinked.first