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