AddPathsToDirectoryQuery(theQuery [, basePath])
Last updated July 9, 2003
Version: 1 | Requires: ColdFusion 5 | Library: FileSysLib
Description:
Adds a "FullPath" column to provided directory query (from <cfdirectory action="LIST">). Handy for keeping track of what files were from where when combining directory queries from multiple directories.
Return Values:
query
Example:
<cfdirectory action="list" directory="#dir#" name="getFiles" filter="*.txt">
ORIGINAL QUERY:<br />
<cfdump var="#getFiles#">
<br /><br />
QUERY WITH NEW FullPath COLUMN:<br />
<cfset addPathsToDirectoryQuery (getFiles, dir)>
<cfdump var="#getFiles#">
Parameters:
| Name | Description | Required |
|---|---|---|
| theQuery | The query returned from CFDIRECTORY | Yes |
| basePath | String containing the path to the directory used in the CFDIRECTORY call | No |
Full UDF Source:
<cfscript>
/**
* Adds a "FullPath" column to provided directory query.
*
* @param theQuery The query returned from CFDIRECTORY (Required)
* @param basePath String containing the path to the directory used in the CFDIRECTORY call (Optional)
* @return query
* @author Shawn Seley (shawnse@aol.com)
* @version 1, July 9, 2003
*/
function addPathsToDirectoryQuery(theQuery, basePath) {
var row = 0;
var new_col_array = arrayNew(1);
if (listFindNoCase(theQuery.columnList, "FullPath")) {
for(row=1; row LTE theQuery.recordCount; row=row+1) {
querySetCell(theQuery, "FullPath", basePath & theQuery.name[row], row);
}
} else {
for(row=1; row LTE theQuery.recordCount; row=row+1) {
new_col_array[row] = basePath & theQuery.name[row];
}
queryAddColumn(theQuery, "FullPath", new_col_array);
}
return theQuery;
}
</cfscript>
Search CFLib.org
Latest Additions
Jose Diaz-Salcedo added
cfRssFeed
2 day(s) ago
Raymond Compton added
structBlend
23 day(s) ago
Duncan added
IsZIPUK
23 day(s) ago
Todd Sharp added
getTagContentAll
29 day(s) ago
Gerald Guido added
ListReturnDuplicat...
1 month(s) ago