summaryrefslogtreecommitdiffstats
path: root/Source/CPack/cmCPackArchiveGenerator.cxx
diff options
context:
space:
mode:
authorBen Boeckel <ben.boeckel@kitware.com>2017-03-01 18:41:50 (GMT)
committerBrad King <brad.king@kitware.com>2017-03-06 15:38:58 (GMT)
commitaba92ffd92bb1cc4bbe898b7abe65347b0468d33 (patch)
tree7fff657ef3fe0dd115886283b808025cfa8faa34 /Source/CPack/cmCPackArchiveGenerator.cxx
parent047a5e4d6656f362151b855b34c259708b8419ba (diff)
downloadCMake-aba92ffd92bb1cc4bbe898b7abe65347b0468d33.zip
CMake-aba92ffd92bb1cc4bbe898b7abe65347b0468d33.tar.gz
CMake-aba92ffd92bb1cc4bbe898b7abe65347b0468d33.tar.bz2
cmWorkingDirectory: use the new class
These functions just need to change the directory for a block of code and then go back to the caller's expected location. Use cmWorkingDirectory to ensure that all return paths are handled.
Diffstat (limited to 'Source/CPack/cmCPackArchiveGenerator.cxx')
-rw-r--r--Source/CPack/cmCPackArchiveGenerator.cxx10
1 files changed, 3 insertions, 7 deletions
diff --git a/Source/CPack/cmCPackArchiveGenerator.cxx b/Source/CPack/cmCPackArchiveGenerator.cxx
index 9d9cd66..cc01b0c 100644
--- a/Source/CPack/cmCPackArchiveGenerator.cxx
+++ b/Source/CPack/cmCPackArchiveGenerator.cxx
@@ -7,6 +7,7 @@
#include "cmCPackLog.h"
#include "cmGeneratedFileStream.h"
#include "cmSystemTools.h"
+#include "cmWorkingDirectory.h"
#include <map>
#include <ostream>
@@ -37,9 +38,8 @@ int cmCPackArchiveGenerator::addOneComponentToArchive(
// Add the files of this component to the archive
std::string localToplevel(this->GetOption("CPACK_TEMPORARY_DIRECTORY"));
localToplevel += "/" + component->Name;
- std::string dir = cmSystemTools::GetCurrentWorkingDirectory();
// Change to local toplevel
- cmSystemTools::ChangeDirectory(localToplevel);
+ cmWorkingDirectory workdir(localToplevel);
std::string filePrefix;
if (this->IsOn("CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY")) {
filePrefix = this->GetOption("CPACK_PACKAGE_FILE_NAME");
@@ -64,8 +64,6 @@ int cmCPackArchiveGenerator::addOneComponentToArchive(
return 0;
}
}
- // Go back to previous dir
- cmSystemTools::ChangeDirectory(dir);
return 1;
}
@@ -227,8 +225,7 @@ int cmCPackArchiveGenerator::PackageFiles()
// CASE 3 : NON COMPONENT package.
DECLARE_AND_OPEN_ARCHIVE(packageFileNames[0], archive);
std::vector<std::string>::const_iterator fileIt;
- std::string dir = cmSystemTools::GetCurrentWorkingDirectory();
- cmSystemTools::ChangeDirectory(toplevel);
+ cmWorkingDirectory workdir(toplevel);
for (fileIt = files.begin(); fileIt != files.end(); ++fileIt) {
// Get the relative path to the file
std::string rp =
@@ -241,7 +238,6 @@ int cmCPackArchiveGenerator::PackageFiles()
return 0;
}
}
- cmSystemTools::ChangeDirectory(dir);
// The destructor of cmArchiveWrite will close and finish the write
return 1;
}