https://github.com/Kitware/CMake
Revision f6c3820549affa910ec5f710ec61f1f3414b13ab authored by Brad King on 27 March 2020, 11:42:33 UTC, committed by Kitware Robot on 27 March 2020, 11:43:02 UTC
4b8297721f CheckIPOSupported: Avoid polluting cache with common name 'result'

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Kyle Edwards <kyle.edwards@kitware.com>
Merge-request: !4528
2 parent s 1915a09 + 4b82977
Raw File
Tip revision: f6c3820549affa910ec5f710ec61f1f3414b13ab authored by Brad King on 27 March 2020, 11:42:33 UTC
Merge topic 'CheckIPOSupported-cleanup-cache' into release-3.17
Tip revision: f6c3820
cmWorkingDirectory.cxx
/* Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
   file Copyright.txt or https://cmake.org/licensing for details.  */
#include "cmWorkingDirectory.h"

#include <cerrno>

#include "cmSystemTools.h"

cmWorkingDirectory::cmWorkingDirectory(std::string const& newdir)
{
  this->OldDir = cmSystemTools::GetCurrentWorkingDirectory();
  this->SetDirectory(newdir);
}

cmWorkingDirectory::~cmWorkingDirectory()
{
  this->Pop();
}

bool cmWorkingDirectory::SetDirectory(std::string const& newdir)
{
  if (cmSystemTools::ChangeDirectory(newdir) == 0) {
    this->ResultCode = 0;
    return true;
  }
  this->ResultCode = errno;
  return false;
}

void cmWorkingDirectory::Pop()
{
  if (!this->OldDir.empty()) {
    this->SetDirectory(this->OldDir);
    this->OldDir.clear();
  }
}
back to top