Some refactoring of FancyZones::IsInterestingWindow and added Unit Tests (#1521)

* Some refactoring of FancyZones::IsInterestingWindow and added UnitTests
This commit is contained in:
Yevhenii Holovachov
2020-03-16 14:25:30 +02:00
committed by GitHub
parent 04027b9c32
commit 02857d1b7f
6 changed files with 85 additions and 6 deletions

View File

@@ -7,6 +7,7 @@
#include "version.h"
#pragma comment(lib, "advapi32.lib")
#pragma comment(lib, "shlwapi.lib")
namespace localized_strings
{
@@ -715,3 +716,18 @@ bool check_user_is_admin()
freeMemory(pSID, pGroupInfo);
return false;
}
bool find_app_name_in_path(const std::wstring& where, const std::vector<std::wstring>& what)
{
for (const auto& row : what)
{
const auto pos = where.rfind(row);
const auto last_slash = where.rfind('\\');
//Check that row occurs in where, and its last occurrence contains in itself the first character after the last backslash.
if (pos != std::wstring::npos && pos <= last_slash + 1 && pos + row.length() > last_slash)
{
return true;
}
}
return false;
}