/* This function searches for DXE capsules from the associated device and returns the number and maximum size in bytes of the capsules discovered. Entry 1 is assumed to be the highest load priority and entry N is assumed to be the lowest priority. */
EFI_STATUS EFIAPI GetNumberRecoveryCapsules(IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_DEVICE_RECOVERY_MODULE_PPI *This, OUT UINTN *NumberRecoveryCapsules)
/* This function searches for DXE capsules from the associated device and returns the number and maximum size in bytes of the capsules discovered. Entry 1 is assumed to be the highest load priority and entry N is assumed to be the lowest priority. */
EFI_STATUS EFIAPI GetNumberRecoveryCapsules(IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_DEVICE_RECOVERY_MODULE_PPI *This, OUT UINTN *NumberRecoveryCapsules)
{
  EFI_STATUS            Status;
  PEI_FAT_PRIVATE_DATA  *PrivateData;
  UINTN                 Index;
  UINTN                 RecoveryCapsuleCount;
  PEI_FILE_HANDLE       Handle;
  PrivateData = PEI_FAT_PRIVATE_DATA_FROM_THIS (This);
  RecoveryCapsuleCount = 0;
  for (Index = 0; Index < PrivateData->VolumeCount; Index++) {
    Status = FindRecoveryFile (PrivateData, Index, (CHAR16 *)PcdGetPtr (PcdRecoveryFileName), &Handle);
    if (EFI_ERROR (Status)) {
      continue;
    }
    RecoveryCapsuleCount++;
  }
  *NumberRecoveryCapsules = RecoveryCapsuleCount;
  if (*NumberRecoveryCapsules == 0) {
    return EFI_NOT_FOUND;
  }
  return EFI_SUCCESS;
}