/* Close the directory entry and free the OFile. */
VOID FatCloseDirEnt(IN FAT_DIRENT *DirEnt)
/* Close the directory entry and free the OFile. */
VOID FatCloseDirEnt(IN FAT_DIRENT *DirEnt)
{
  FAT_OFILE   *OFile;
  FAT_VOLUME  *Volume;
  OFile = DirEnt->OFile;
  ASSERT (OFile != NULL);
  Volume = OFile->Volume;
  if (OFile->ODir != NULL) {
    FatDiscardODir (OFile);
  }
  if (OFile->Parent == NULL) {
    Volume->Root = NULL;
  } else {
    RemoveEntryList (&OFile->ChildLink);
  }
  FreePool (OFile);
  DirEnt->OFile = NULL;
  if (DirEnt->Invalid == TRUE) {
    FatFreeDirEnt (DirEnt);
  }
}