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
Tayo Akinmade added
arrayTrim
12 day(s) ago
Will Belden added
longTime
17 day(s) ago
James Sleeman added
quickSort
27 day(s) ago
Ben Forta added
GetHostAddress
30 day(s) ago
Top Rated
EksporSQLData
Rated 5.0, 16 time(s)
backupDatabase
Rated 5.0, 13 time(s)
indentXml
Rated 5.0, 10 time(s)
generateSsccAsn
Rated 5.0, 4 time(s)