/* Adds a new FFS file. Extends the firmware volume if needed. */
EFI_STATUS FvBufAddFileWithExtend(IN OUT VOID **Fv, IN VOID *File)
/* Adds a new FFS file. Extends the firmware volume if needed. */
EFI_STATUS FvBufAddFileWithExtend(IN OUT VOID **Fv, IN VOID *File)
{
  EFI_STATUS Status;
  EFI_FFS_FILE_HEADER* NewFile;
  NewFile = (EFI_FFS_FILE_HEADER*)File;
  Status = FvBufAddFile (*Fv, NewFile);
  if (Status == EFI_OUT_OF_RESOURCES) {
    Status = FvBufExtend (Fv, FvBufExpand3ByteSize (NewFile->Size));
    if (EFI_ERROR (Status)) {
      return Status;
    }
    Status = FvBufAddFile (*Fv, NewFile);
  }
  return Status;
}