BOOLEAN DirIterNext(IN OUT REFIT_DIR_ITER *DirIter, IN UINTN FilterMode, IN CHAR16 *FilePattern OPTIONAL,
OUT EFI_FILE_INFO **DirEntry)
{
+ BOOLEAN KeepGoing = TRUE;
+ UINTN i;
+ CHAR16 *OnePattern;
+
if (DirIter->LastFileInfo != NULL) {
FreePool(DirIter->LastFileInfo);
DirIter->LastFileInfo = NULL;
if (EFI_ERROR(DirIter->LastStatus))
return FALSE; // stop iteration
- for (;;) {
+ do {
DirIter->LastStatus = DirNextEntry(DirIter->DirHandle, &(DirIter->LastFileInfo), FilterMode);
if (EFI_ERROR(DirIter->LastStatus))
return FALSE;
return FALSE;
if (FilePattern != NULL) {
if ((DirIter->LastFileInfo->Attribute & EFI_FILE_DIRECTORY))
- break;
- if (MetaiMatch(DirIter->LastFileInfo->FileName, FilePattern))
- break;
+ KeepGoing = FALSE;
+ i = 0;
+ while (KeepGoing && (OnePattern = FindCommaDelimited(FilePattern, i++)) != NULL) {
+ if (MetaiMatch(DirIter->LastFileInfo->FileName, OnePattern))
+ KeepGoing = FALSE;
+ } // while
// else continue loop
} else
break;
- }
+ } while (KeepGoing);
*DirEntry = DirIter->LastFileInfo;
return TRUE;
// Find the #Index element (numbered from 0) in a comma-delimited string
// of elements.
// Returns the found element, or NULL if Index is out of range or InString
-// is NULL.
+// is NULL. Note that the calling function is responsible for freeing the
+// memory associated with the returned string pointer.
CHAR16 *FindCommaDelimited(IN CHAR16 *InString, IN UINTN Index) {
UINTN StartPos = 0, CurPos = 0;
BOOLEAN Found = FALSE;