2012-10-16 20:41:16 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
#define DEFINE_UNICODE FALSE
|
2012-10-17 01:18:12 +04:00
|
|
|
#define _PATH_SEPARATOR_CHR '\\'
|
2012-10-16 20:41:16 +04:00
|
|
|
#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)
|
2015-06-02 22:38:49 +03:00
|
|
|
return E_INVALIDARG;
|
2012-10-16 20:41:16 +04:00
|
|
|
|
|
|
|
pszPathLength = lstrlenW(pszPath);
|
|
|
|
|
2012-10-17 01:18:12 +04:00
|
|
|
if (pszPath[pszPathLength - 1] == _PATH_SEPARATOR_CHR)
|
2012-10-16 20:41:16 +04:00
|
|
|
return S_FALSE;
|
|
|
|
|
|
|
|
if (cchPath > (pszPathLength + 1))
|
|
|
|
{
|
2012-10-17 01:18:12 +04:00
|
|
|
pszPath[pszPathLength] = _PATH_SEPARATOR_CHR;
|
2012-10-16 20:41:16 +04:00
|
|
|
pszPath[pszPathLength + 1] = '\0';
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2015-06-02 22:38:49 +03:00
|
|
|
return HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER);
|
2012-10-16 20:41:16 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
HRESULT PATH_CCH_ADD_SEPARATOR_EX(PSTR pszPath, size_t cchPath, PSTR* ppszEnd, size_t* pcchRemaining)
|
|
|
|
{
|
|
|
|
size_t pszPathLength;
|
|
|
|
|
|
|
|
if (!pszPath)
|
2015-06-02 22:38:49 +03:00
|
|
|
return E_INVALIDARG;
|
2012-10-16 20:41:16 +04:00
|
|
|
|
|
|
|
pszPathLength = lstrlenA(pszPath);
|
|
|
|
|
2012-10-17 01:18:12 +04:00
|
|
|
if (pszPath[pszPathLength - 1] == _PATH_SEPARATOR_CHR)
|
2012-10-16 20:41:16 +04:00
|
|
|
return S_FALSE;
|
|
|
|
|
|
|
|
if (cchPath > (pszPathLength + 1))
|
|
|
|
{
|
2012-10-17 01:18:12 +04:00
|
|
|
pszPath[pszPathLength] = _PATH_SEPARATOR_CHR;
|
2012-10-16 20:41:16 +04:00
|
|
|
pszPath[pszPathLength + 1] = '\0';
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2015-06-02 22:38:49 +03:00
|
|
|
return HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER);
|
2012-10-16 20:41:16 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
#undef DEFINE_UNICODE
|
2012-10-17 01:18:12 +04:00
|
|
|
#undef _PATH_SEPARATOR_CHR
|
2012-10-16 20:41:16 +04:00
|
|
|
#undef PATH_CCH_ADD_SEPARATOR_EX
|
|
|
|
*/
|
|
|
|
|