/* Discard the directory structure when an OFile will be freed. Volume will cache this directory if the OFile does not represent a deleted file. */
VOID FatDiscardODir(IN FAT_OFILE *OFile)
/* Discard the directory structure when an OFile will be freed. Volume will cache this directory if the OFile does not represent a deleted file. */
VOID FatDiscardODir(IN FAT_OFILE *OFile)
{
  FAT_ODIR    *ODir;
  FAT_VOLUME  *Volume;
  Volume = OFile->Volume;
  ODir   = OFile->ODir;
  if (!OFile->DirEnt->Invalid) {
    ODir->DirCacheTag = OFile->FileCluster;
    InsertHeadList (&Volume->DirCacheList, &ODir->DirCacheLink);
    if (Volume->DirCacheCount == FAT_MAX_DIR_CACHE_COUNT) {
      ODir = ODIR_FROM_DIRCACHELINK (Volume->DirCacheList.BackLink);
      RemoveEntryList (&ODir->DirCacheLink);
    } else {
      Volume->DirCacheCount++;
      ODir = NULL;
    }
  }
  if (ODir != NULL) {
    FatFreeODir (ODir);
  }
}