mirror of
https://github.com/Kitware/CMake.git
synced 2025-05-09 06:42:18 +08:00

``` git grep -lz 'Copyright.txt or https://cmake.org/licensing ' | while IFS= read -r -d $'\0' f ; do sed -i '/Copyright.txt or https:\/\/cmake.org\/licensing / { s/Copyright.txt/LICENSE.rst/ }' "$f" ; done ```
38 lines
953 B
C++
38 lines
953 B
C++
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
file LICENSE.rst or https://cmake.org/licensing for details. */
|
|
#include "cmWorkingDirectory.h"
|
|
|
|
#include "cmStringAlgorithms.h"
|
|
#include "cmSystemTools.h"
|
|
|
|
cmWorkingDirectory::cmWorkingDirectory(std::string const& newdir)
|
|
{
|
|
this->OldDir = cmSystemTools::GetLogicalWorkingDirectory();
|
|
this->SetDirectory(newdir);
|
|
}
|
|
|
|
cmWorkingDirectory::~cmWorkingDirectory()
|
|
{
|
|
this->Pop();
|
|
}
|
|
|
|
bool cmWorkingDirectory::SetDirectory(std::string const& newdir)
|
|
{
|
|
cmsys::Status status = cmSystemTools::SetLogicalWorkingDirectory(newdir);
|
|
if (status) {
|
|
this->Error.clear();
|
|
return true;
|
|
}
|
|
this->Error = cmStrCat("Failed to change working directory to \"", newdir,
|
|
"\": ", status.GetString());
|
|
return false;
|
|
}
|
|
|
|
void cmWorkingDirectory::Pop()
|
|
{
|
|
if (!this->OldDir.empty()) {
|
|
this->SetDirectory(this->OldDir);
|
|
this->OldDir.clear();
|
|
}
|
|
}
|