CFX_ListDir
|
|---|
This tag is a working replacement for <CFDIRECTORY ACTION="list" ... >
The results returned by CFDIRECTORY are far from being complete and useful:
CFX_ListDir is an attempt to fix these flaws, and to give more accurate and detailed information, in a consistent way under any CF version (It was not tested for CF 4, but there is no reason it should not work as well).
The main feature in CFX_ListDir are:
To use this tag, you need to take the included CFX_ListDir.dll, install it on a drive on your server and make it known to the ColdFusion administrator.
You do this by going to the "CFX Tags" tab in the administrator,
That's it!
For more information refer to the ColdFusion documentation "Managing CFXs".
<CFX_ListDir
| DIRECTORY | = <full path name of the directory to list"> |
| [NAME] | = <Name for output record set.> |
| [QUERY] | = <Name of an optional query to append results to.> |
| [FILTER] | = <File extension filter applied to returned names;> |
| [EXTENSIONS] | = <List of file extensions> |
| [MODIFIEDBEFORE] | = <limit file list to those modified before this date> |
| [MODIFIEDAFTER] | = <limit file list to those modified after this date> |
| [TYPE] | = <file or dir, to list only files or directories> |
| [READONLY] | = <select files according to their read-only attribute> |
| [SYSTEM] | = <select files according to their system attribute> |
| [HIDDEN] | = <select files according to their hidden attribute> |
| [ARCHIVE] | = <select files according to their archive attribute> |
| [RECURSE] | = <Whether the tag performs the action on subdirectories> |
| [SORT] | = <Query column(s) by which to sort directory listing> |
| > |
| TAG | ATTRIBUTE | CONTENT | REQUIRED | DEFAULT |
|---|---|---|---|---|
| <CFX_ListDir | DIRECTORY= | Full path name of the directory to list. (ex: C:\inetsrv\wwwroot) | Yes | N/A |
| NAME= | Name of the query to be returned by CFX_ListDir. | No | "listDir" | |
| QUERY= | If this attribute is supplied, and it contains a query compatible with queries generated by CFX_ListDir, the record set will be appended to this query and no new query will be created. Use this attribute to create a larger query containing list of files in several independant directories.
Furthermore, one can call the tag with only the NAME attribute, and QUERY set to an empty string. This will just create an empty query with all appropriate columns, and this query may be used later to append new record set to it (see last example below). |
No | "listDir" | |
| FILTER= | File extension filter applied to returned names; for example, *.cfm. One filter can be applied. Use attribute EXTENSION for an alternative way to select file names. The filter may use wildcard characters like ? or *. | No | "*.*" | |
| EXTENSIONS= | Comma separated list of file extension to be used as filter on file names. Ex: "cfm,css,htm,html,js".
Notes:
|
No | "" | |
| MODIFIEDBEFORE= | Use this attribute to provide a date to select only files modified before this date. The date must be supplied in ODBCDateTime format, not just ODBCDate (see CreateODBCDateTime () function). | No | "" | |
| MODIFIEDAFTER= | Use this attribute to provide a date to select only files modified after this date. The date must be supplied in ODBCDateTime format, not just ODBCDate (see CreateODBCDateTime () function). | No | N/A | |
| TYPE="file|dir" | Use this attribute with values "file" or "dir" to limite output to files only or directories only respectively. | No | "" | |
| READONLY="yes|no" | With READONLY="yes", the tag will only list files having the read-only attribute set.
With READONLY="no", the tag will only list files having the read-only attribute NOT set. |
No | N/A | |
| SYSTEM="yes|no" | With SYSTEM="yes", the tag will only list files having the system attribute set.
With SYSTEM="no", the tag will only list files having the system attribute NOT set. |
No | N/A | |
| HIDDEN="yes|no" | With HIDDEN="yes", the tag will only list files having the hidden attribute set.
With HIDDEN="no", the tag will only list files having the hidden attribute NOT set. |
No | N/A | |
| ARCHIVE="yes|no" | With ARCHIVE="yes", the tag will only list files having the archive attribute set.
With ARCHIVE="no", the tag will only list files having the archive attribute NOT set. |
No | N/A | |
| RECURSE | Whether ColdFusion performs the action on subdirectories. Only the presence of the attribute is needed, for instance, with RECURSE="no", the tag will still perform recursively. | No | N/A | |
| SORT= | This is a list of a maximum of two columns that may be used to sort the query. Any column may be used. The sort is alway in ascending order, no ASC or DESC modifier may be used. | No | "" |
| COLUMNS RETUNED BY THE QUERY |
|---|
| Column Name | Description of Content |
|---|---|
| Name | Name of the File or directory; Ex: myTemplate.cfm (CFDIRECTORY compatible). |
| directory | Full path name of the directory in which the file is; Ex: C:\inetsrv\wwwroot\MySite (CFDIRECTORY compatible). |
| size | Size of the file in bytes, or 0 for a directory (CFDIRECTORY compatible). |
| type | Either "File" for a file, or "Dir" for a directory (CFDIRECTORY compatible). |
| readOnly | Either "Yes" or "no", according to the corresponding file attribute (Addition to CFDIRECTORY). |
| System | Either "Yes" or "no", according to the corresponding file attribute (Addition to CFDIRECTORY). |
| Hidden | Either "Yes" or "no", according to the corresponding file attribute (Addition to CFDIRECTORY). |
| Archive | Either "Yes" or "no", according to the corresponding file attribute (Addition to CFDIRECTORY). |
| dateLastModified | Date the file was last modified, in full ODBCDateTime format; Ex: {ts '2004-02-02 14:11:57'} (Improvement to CFDIRECTORY) |
| dateCreated | Date the file was created, in full ODBCDateTime format; Ex: {ts '2004-02-02 14:11:57'} (Addition to CFDIRECTORY). |
| dateLastAccess | Date the file was last accessed, in full ODBCDateTime format; Ex: {ts '2004-02-02 14:11:57'} (Addition to CFDIRECTORY). |
<CFX_LISTDIR DIRECTORY="C:\inetsrv\wwwroot\CustomTags" NAME="getDir" SORT="directory,name" RECURSE EXTENSIONS="cfm,css,htm,html,js" >
<CFX_LISTDIR
DIRECTORY="C:\inetsrv\wwwroot\CustomTags"
NAME="getDir"
SORT="dateLastModified"
RECURSE
EXTENSIONS="cfm,css,htm,html,js"
MODIFIEDAFTER="#CreateODBCDate (dateAdd ("YYYY", -1, now()))#"
>
<CFX_LISTDIR DIRECTORY="C:\inetsrv\wwwroot\CustomTags" READONLY="yes" RECURSE >
<!--- Create an empty query "getDir" --->
<CFX_LISTDIR QUERY="" NAME="getDir">
<!--- Append files from mapClick --->
<CFX_LISTDIR QUERY="getDir"
FILTER="*.cfm"
DIRECTORY="C:\inetsrv\wwwroot\CustomTags\mapClick">
<!--- Append files from mapData --->
<CFX_LISTDIR QUERY="getDir"
FILTER="*.cfm"
DIRECTORY="C:\inetsrv\wwwroot\CustomTags\mapData">
<!--- Append files from stampImage --->
<CFX_LISTDIR QUERY="getDir"
FILTER="*.cfm"
DIRECTORY="C:\inetsrv\wwwroot\CustomTags\stampImage">