Coverage Report

Created: 2026-03-12 06:35

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/CMake/Source/kwsys/Status.cxx
Line
Count
Source
1
/* Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
2
   file Copyright.txt or https://cmake.org/licensing#kwsys for details.  */
3
#include "kwsysPrivate.h"
4
#include KWSYS_HEADER(Status.hxx)
5
#include KWSYS_HEADER(Encoding.hxx)
6
7
// Work-around CMake dependency scanning limitation.  This must
8
// duplicate the above list of headers.
9
#if 0
10
#  include "Encoding.hxx.in"
11
#  include "Status.hxx.in"
12
#endif
13
14
#include <cerrno>
15
#include <cstring>
16
#include <string>
17
18
#if defined(_WIN32)
19
#  include <windows.h>
20
#endif
21
22
namespace KWSYS_NAMESPACE {
23
24
Status Status::POSIX_errno()
25
35.5k
{
26
35.5k
  return Status::POSIX(errno);
27
35.5k
}
28
29
#ifdef _WIN32
30
Status Status::Windows_GetLastError()
31
{
32
  return Status::Windows(GetLastError());
33
}
34
#endif
35
36
std::string Status::GetString() const
37
0
{
38
0
  std::string err;
39
0
  switch (this->Kind_) {
40
0
    case Kind::Success:
41
0
      err = "Success";
42
0
      break;
43
0
    case Kind::POSIX:
44
0
      err = strerror(this->POSIX_);
45
0
      break;
46
#ifdef _WIN32
47
    case Kind::Windows: {
48
      LPWSTR message = NULL;
49
      DWORD size = FormatMessageW(
50
        FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
51
          FORMAT_MESSAGE_IGNORE_INSERTS,
52
        NULL, this->Windows_, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
53
        (LPWSTR)&message, 0, NULL);
54
      err = kwsys::Encoding::ToNarrow(message);
55
      LocalFree(message);
56
    } break;
57
#endif
58
0
    default:
59
0
      break;
60
0
  }
61
0
  return err;
62
0
}
63
64
} // namespace KWSYS_NAMESPACE