[RAPPS] move icon to a field in .txt file (#2941)

* [RAPPS] move icon to a field in .txt file
* [RAPPS] add function PathAppendNoDirEscapeW, apply it.
This commit is contained in:
He Yang 2020-06-30 04:40:40 +08:00 committed by Mark Jansen
parent e636373016
commit 4482d0f455
No known key found for this signature in database
GPG key ID: B39240EE84BEAE8B
5 changed files with 93 additions and 16 deletions

View file

@ -407,3 +407,49 @@ BOOL CConfigParser::GetInt(const ATL::CStringW& KeyName, INT& iResult)
return (iResult > 0);
}
// CConfigParser
BOOL PathAppendNoDirEscapeW(LPWSTR pszPath, LPCWSTR pszMore)
{
WCHAR pszPathBuffer[MAX_PATH]; // buffer to store result
WCHAR pszPathCopy[MAX_PATH];
if (!PathCanonicalizeW(pszPathCopy, pszPath))
{
return FALSE;
}
PathRemoveBackslashW(pszPathCopy);
if (StringCchCopyW(pszPathBuffer, _countof(pszPathBuffer), pszPathCopy) != S_OK)
{
return FALSE;
}
if (!PathAppendW(pszPathBuffer, pszMore))
{
return FALSE;
}
size_t PathLen;
if (StringCchLengthW(pszPathCopy, _countof(pszPathCopy), &PathLen) != S_OK)
{
return FALSE;
}
int CommonPrefixLen = PathCommonPrefixW(pszPathCopy, pszPathBuffer, NULL);
if ((unsigned int)CommonPrefixLen != PathLen)
{
// pszPathBuffer should be a file/folder under pszPath.
// but now common prefix len is smaller than length of pszPathCopy
// hacking use ".." ?
return FALSE;
}
if (StringCchCopyW(pszPath, MAX_PATH, pszPathBuffer) != S_OK)
{
return FALSE;
}
return TRUE;
}