From 93862405ed6bbf1a729205db6e4083de76dca623 Mon Sep 17 00:00:00 2001 From: Pheenoh Date: Mon, 19 Aug 2024 21:00:15 -0600 Subject: [PATCH] move empty pattern check into while loop (#81) --- dll/kernel32.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/dll/kernel32.cpp b/dll/kernel32.cpp index e504446..17bcd46 100644 --- a/dll/kernel32.cpp +++ b/dll/kernel32.cpp @@ -701,16 +701,10 @@ namespace kernel32 { return false; } - // If pattern is empty, just iterate - if (handle->pattern.empty()) { - handle->it++; - return handle->it != std::filesystem::directory_iterator(); - } - // Look for a matching file with the pattern while (handle->it != std::filesystem::directory_iterator()) { std::filesystem::path path = *handle->it; - if (fnmatch(handle->pattern.c_str(), path.filename().c_str(), 0) == 0) { + if (!handle->pattern.empty() && fnmatch(handle->pattern.c_str(), path.filename().c_str(), 0) == 0) { return true; } handle->it++;