/* This service searches for files with a specific name, within either the specified firmware volume or all firmware volumes. */
EFI_STATUS EFIAPI PeiFfsFvPpiFindFileByName(IN CONST EFI_PEI_FIRMWARE_VOLUME_PPI *This, IN CONST EFI_GUID *FileName, IN EFI_PEI_FV_HANDLE *FvHandle, OUT EFI_PEI_FILE_HANDLE *FileHandle)
/* This service searches for files with a specific name, within either the specified firmware volume or all firmware volumes. */
EFI_STATUS EFIAPI PeiFfsFvPpiFindFileByName(IN CONST EFI_PEI_FIRMWARE_VOLUME_PPI *This, IN CONST EFI_GUID *FileName, IN EFI_PEI_FV_HANDLE *FvHandle, OUT EFI_PEI_FILE_HANDLE *FileHandle)
{
  EFI_STATUS         Status;
  PEI_CORE_INSTANCE  *PrivateData;
  UINTN              Index;
  if ((FvHandle == NULL) || (FileName == NULL) || (FileHandle == NULL)) {
    return EFI_INVALID_PARAMETER;
  }
  if (*FvHandle != NULL) {
    Status = FindFileEx (*FvHandle, FileName, 0, FileHandle, NULL);
    if (Status == EFI_NOT_FOUND) {
      *FileHandle = NULL;
    }
  } else {
    Status = EFI_NOT_FOUND;
    PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS (GetPeiServicesTablePointer ());
    for (Index = 0; Index < PrivateData->FvCount; Index++) {
      if (PrivateData->Fv[Index].FvPpi != NULL) {
        Status = FindFileEx (PrivateData->Fv[Index].FvHandle, FileName, 0, FileHandle, NULL);
        if (!EFI_ERROR (Status)) {
          *FvHandle = PrivateData->Fv[Index].FvHandle;
          break;
        }
      }
    }
  }
  return Status;
}