blob: 02832d858c5e94e844eff8db30ea26153a628741 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
/*
#define DEFINE_UNICODE FALSE
#define CUR_PATH_SEPARATOR_CHR '\\'
#define PATH_CCH_ADD_SEPARATOR_EX PathCchAddBackslashExA
*/
#if DEFINE_UNICODE
HRESULT PATH_CCH_ADD_SEPARATOR_EX(PWSTR pszPath, size_t cchPath, PWSTR* ppszEnd,
size_t* pcchRemaining)
{
size_t pszPathLength;
if (!pszPath)
return E_INVALIDARG;
pszPathLength = _wcslen(pszPath);
if (pszPath[pszPathLength - 1] == CUR_PATH_SEPARATOR_CHR)
return S_FALSE;
if (cchPath > (pszPathLength + 1))
{
pszPath[pszPathLength] = CUR_PATH_SEPARATOR_CHR;
pszPath[pszPathLength + 1] = '\0';
return S_OK;
}
return HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER);
}
#else
HRESULT PATH_CCH_ADD_SEPARATOR_EX(PSTR pszPath, size_t cchPath, PSTR* ppszEnd,
size_t* pcchRemaining)
{
size_t pszPathLength;
if (!pszPath)
return E_INVALIDARG;
pszPathLength = strlen(pszPath);
if (pszPath[pszPathLength - 1] == CUR_PATH_SEPARATOR_CHR)
return S_FALSE;
if (cchPath > (pszPathLength + 1))
{
pszPath[pszPathLength] = CUR_PATH_SEPARATOR_CHR;
pszPath[pszPathLength + 1] = '\0';
return S_OK;
}
return HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER);
}
#endif
/*
#undef DEFINE_UNICODE
#undef CUR_PATH_SEPARATOR_CHR
#undef PATH_CCH_ADD_SEPARATOR_EX
*/
|