<!--- 
  <CF_DeleteCacheFiles> Custom Tag by Nate Weiss (March, 2001)

  Example of use:
  <CF_DeleteCacheFiles
    CacheDirectory="directory_used_in_cfcache_tag">
    
  The CacheDirectory is optional. Defaults to current directory.
  See the "Improving Performance" chapter for details.
--->

<!--- Required Tag Attribute. Default to current page --->
<CFPARAM NAME="ATTRIBUTES.CacheDirectory" TYPE="string" DEFAULT="#GetDirectoryFromPath(GetBaseTemplatePath())#">

<!--- If the directory exists --->
<CFIF DirectoryExists(ATTRIBUTES.CacheDirectory)>

  <!--- If there is a cfcache.map file in the directory, delete it --->
  <CFSET MapFile = "#ATTRIBUTES.CacheDirectory#\cfcache.map"> 
  <CFIF FileExists(MapFile)>
    <CFFILE
      ACTION="DELETE"
      FILE="#MapFile#">
  </CFIF>

  <!--- Get a list of all the cache "tmp" files --->   
  <CFDIRECTORY
    ACTION="List"
    DIRECTORY="#ATTRIBUTES.CacheDirectory#"
    FILTER="CFC*.tmp"
    NAME="GetFiles">
    
  <!--- Delete each of the "tmp" files --->  
  <CFLOOP QUERY="GetFiles">
    <CFFILE
      ACTION="DELETE"
      FILE="#ATTRIBUTES.CacheDirectory#\#GetFiles.Name#">
  </CFLOOP>  
</CFIF>