/* Set the directory's cursor to the next and get the next directory entry. */
EFI_STATUS FatGetNextDirEnt(IN FAT_OFILE *OFile, OUT FAT_DIRENT **PtrDirEnt)
/* Set the directory's cursor to the next and get the next directory entry. */
EFI_STATUS FatGetNextDirEnt(IN FAT_OFILE *OFile, OUT FAT_DIRENT **PtrDirEnt)
{
  EFI_STATUS  Status;
  FAT_DIRENT  *DirEnt;
  FAT_ODIR    *ODir;
  ODir = OFile->ODir;
  ASSERT (ODir != NULL);
  if (ODir->CurrentCursor->ForwardLink == &ODir->ChildList) {
    if (!ODir->EndOfDir) {
      Status = FatLoadNextDirEnt (OFile, &DirEnt);
      if (EFI_ERROR (Status)) {
        return Status;
      }
    }
  }
  if (ODir->CurrentCursor->ForwardLink == &ODir->ChildList) {
    DirEnt           = NULL;
    ODir->CurrentPos = ODir->CurrentEndPos;
  } else {
    ODir->CurrentCursor = ODir->CurrentCursor->ForwardLink;
    DirEnt              = DIRENT_FROM_LINK (ODir->CurrentCursor);
    ODir->CurrentPos    = DirEnt->EntryPos + 1;
  }
  *PtrDirEnt = DirEnt;
  return EFI_SUCCESS;
}