/* Get the file info from the open file of the IFile into Buffer. */
EFI_STATUS FatIFileReadDir(IN FAT_IFILE *IFile, IN OUT UINTN *BufferSize, OUT VOID *Buffer)
/* Get the file info from the open file of the IFile into Buffer. */
EFI_STATUS FatIFileReadDir(IN FAT_IFILE *IFile, IN OUT UINTN *BufferSize, OUT VOID *Buffer)
{
  EFI_STATUS  Status;
  FAT_OFILE   *OFile;
  FAT_ODIR    *ODir;
  FAT_DIRENT  *DirEnt;
  UINT32      CurrentPos;
  OFile      = IFile->OFile;
  ODir       = OFile->ODir;
  CurrentPos = ((UINT32)IFile->Position) / sizeof (FAT_DIRECTORY_ENTRY);
  if (CurrentPos < ODir->CurrentPos) {
    FatResetODirCursor (OFile);
  }
  do {
    Status = FatGetNextDirEnt (OFile, &DirEnt);
    if (EFI_ERROR (Status) || (DirEnt == NULL)) {
      *BufferSize = 0;
      goto Done;
    }
  } while (ODir->CurrentPos <= CurrentPos);
  Status = FatGetDirEntInfo (OFile->Volume, DirEnt, BufferSize, Buffer);
Done:
  if (!EFI_ERROR (Status)) {
    CurrentPos      = ODir->CurrentPos;
    IFile->Position = CurrentPos * sizeof (FAT_DIRECTORY_ENTRY);
  }
  return Status;
}