From 3a9403a2f153f70419297bf21334a849a6ed54ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 9 Feb 2023 09:51:51 +0800 Subject: [PATCH] Packages (Windows): optimise --- src/detection/packages/packages_windows.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/detection/packages/packages_windows.c b/src/detection/packages/packages_windows.c index 46a36dc46..086a10ea1 100644 --- a/src/detection/packages/packages_windows.c +++ b/src/detection/packages/packages_windows.c @@ -7,6 +7,7 @@ static uint32_t getNumElements(const char* searchPath /* including `\*` suffix */, DWORD type, const char* ignore) { uint32_t counter = 0; + bool flag = ignore == NULL; WIN32_FIND_DATAA wfd; HANDLE hFind = FindFirstFileA(searchPath, &wfd); @@ -15,7 +16,11 @@ static uint32_t getNumElements(const char* searchPath /* including `\*` suffix * do // Managed to locate and create an handle to that folder. { if(!(wfd.dwFileAttributes & type)) continue; - if(ignore != NULL && strcasecmp(ignore, wfd.cFileName) == 0) continue; + if(!flag && strcasecmp(ignore, wfd.cFileName) == 0) + { + flag = true; + continue; + } counter++; } while (FindNextFileA(hFind, &wfd)); FindClose(hFind);