findNextFile improvement (#82)

* move empty pattern check into while loop

* early return if pattern is empty

* comment
This commit is contained in:
Howard Luck
2025-06-01 07:22:17 -06:00
committed by GitHub
parent 93862405ed
commit c01d9a25b9

View File

@@ -701,10 +701,15 @@ namespace kernel32 {
return false;
}
// Early return if pattern is empty
if (handle->pattern.empty()) {
return false;
}
// Look for a matching file with the pattern
while (handle->it != std::filesystem::directory_iterator()) {
std::filesystem::path path = *handle->it;
if (!handle->pattern.empty() && fnmatch(handle->pattern.c_str(), path.filename().c_str(), 0) == 0) {
if (fnmatch(handle->pattern.c_str(), path.filename().c_str(), 0) == 0) {
return true;
}
handle->it++;