Coverage Report

Created: 2026-03-12 06:35

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/CMake/Source/cmWorkingDirectory.cxx
Line
Count
Source
1
/* Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
2
   file LICENSE.rst or https://cmake.org/licensing for details.  */
3
#include "cmWorkingDirectory.h"
4
5
#include "cmStringAlgorithms.h"
6
#include "cmSystemTools.h"
7
8
cmWorkingDirectory::cmWorkingDirectory(std::string const& newdir)
9
0
{
10
0
  this->OldDir = cmSystemTools::GetLogicalWorkingDirectory();
11
0
  this->SetDirectory(newdir);
12
0
}
13
14
cmWorkingDirectory::~cmWorkingDirectory()
15
0
{
16
0
  this->Pop();
17
0
}
18
19
bool cmWorkingDirectory::SetDirectory(std::string const& newdir)
20
0
{
21
0
  cmsys::Status status = cmSystemTools::SetLogicalWorkingDirectory(newdir);
22
0
  if (status) {
23
0
    this->Error.clear();
24
0
    return true;
25
0
  }
26
0
  this->Error = cmStrCat("Failed to change working directory to \"", newdir,
27
0
                         "\": ", status.GetString());
28
0
  return false;
29
0
}
30
31
void cmWorkingDirectory::Pop()
32
0
{
33
0
  if (!this->OldDir.empty()) {
34
0
    this->SetDirectory(this->OldDir);
35
0
    this->OldDir.clear();
36
0
  }
37
0
}