Coverage Report

Created: 2024-05-20 06:11

/src/FreeRDP/winpr/libwinpr/path/include/PathCchAddSeparatorEx.c
Line
Count
Source (jump to first uncovered line)
1
2
/*
3
#define DEFINE_UNICODE      FALSE
4
#define CUR_PATH_SEPARATOR_CHR    '\\'
5
#define PATH_CCH_ADD_SEPARATOR_EX PathCchAddBackslashExA
6
*/
7
8
#if DEFINE_UNICODE
9
10
HRESULT PATH_CCH_ADD_SEPARATOR_EX(PWSTR pszPath, size_t cchPath, PWSTR* ppszEnd,
11
                                  size_t* pcchRemaining)
12
0
{
13
0
  size_t pszPathLength;
14
15
0
  if (!pszPath)
16
0
    return E_INVALIDARG;
17
18
0
  pszPathLength = _wcslen(pszPath);
19
20
0
  if (pszPath[pszPathLength - 1] == CUR_PATH_SEPARATOR_CHR)
21
0
    return S_FALSE;
22
23
0
  if (cchPath > (pszPathLength + 1))
24
0
  {
25
0
    pszPath[pszPathLength] = CUR_PATH_SEPARATOR_CHR;
26
0
    pszPath[pszPathLength + 1] = '\0';
27
28
0
    return S_OK;
29
0
  }
30
31
0
  return HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER);
32
0
}
Unexecuted instantiation: PathCchAddBackslashExW
Unexecuted instantiation: PathCchAddSlashExW
Unexecuted instantiation: PathCchAddSeparatorExW
33
34
#else
35
36
HRESULT PATH_CCH_ADD_SEPARATOR_EX(PSTR pszPath, size_t cchPath, PSTR* ppszEnd,
37
                                  size_t* pcchRemaining)
38
0
{
39
0
  size_t pszPathLength;
40
41
0
  if (!pszPath)
42
0
    return E_INVALIDARG;
43
44
0
  pszPathLength = strlen(pszPath);
45
46
0
  if (pszPath[pszPathLength - 1] == CUR_PATH_SEPARATOR_CHR)
47
0
    return S_FALSE;
48
49
0
  if (cchPath > (pszPathLength + 1))
50
0
  {
51
0
    pszPath[pszPathLength] = CUR_PATH_SEPARATOR_CHR;
52
0
    pszPath[pszPathLength + 1] = '\0';
53
54
0
    return S_OK;
55
0
  }
56
57
0
  return HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER);
58
0
}
Unexecuted instantiation: PathCchAddBackslashExA
Unexecuted instantiation: PathCchAddSlashExA
Unexecuted instantiation: PathCchAddSeparatorExA
59
60
#endif
61
62
/*
63
#undef DEFINE_UNICODE
64
#undef CUR_PATH_SEPARATOR_CHR
65
#undef PATH_CCH_ADD_SEPARATOR_EX
66
*/