3-1-Tags:CFDirectory
last edited by
frinky
on 14-Nov-2010
Contents |
cfdirectory
Description
Handles interactions with directories.
Category
Other
Implemented
Usage Syntax
<cfdirectory [action="String"] [listinfo="String"] [acl="String"] [storage="String"] [type="String"] [serverpassword="String"] directory="String" [name="String"] [filter="String or Custom Function"] [mode="String"] [sort="String"] [newDirectory="String"] [recurse="Boolean"] />
[] = Optional attribute
Attributes
| Name | Type | Required | Default | Description |
| action | String | No | Defines the action to be taken with directory(ies) specified in directory. | |
| listinfo | String | No | Used when action="list". Possible values: "name", "all". By default, cfdirectory returns the columns "name, size, type, dateLastModified, attributes, mode, directory". With the "listinfo" argument set to "name", only the "name" column is returned. | |
| acl | String | No | only used for S3 Resources | |
| storage | String | No | only used for S3 Resources | |
| type | String | No | Can be set to "file", "dir", or "all". This determines which type(s) are returned: only files, only directories, or both (= default). | |
| serverpassword | String | No | allow you to access filesystem, also when access is denied for your context | |
| directory | String | Yes | The name of the directory to perform the action against. | |
| name | String | No | Required for action = "list". Ignored by all other actions. Name of output query for directory listing. | |
| filter | String or Custom Function | No | Optional for action = "list". Ignored by all other actions.
File extension filter applied to returned names. For example: "*.gif" or "*user*.txt". Multiple mask filters can be applied by delimiting them with a pipe character, like this: "*.gif|*.jpg|*.png". You can also use your own custom function as the filter. The function must return a boolean value True or False, indicating whether the given file/directory path should be added to the directory listing. See the example code underneath. | |
| mode | String | No | Used with action = "Create" to define the permissions for a directory on UNIX and Linux platforms. Ignored on Windows. Options correspond to the octal values of the UNIX chmod command. From left to right, permissions are assigned for owner, group, and other. | |
| sort | String | No | Optional for action = "list". Ignored by all other actions. The query columns by which to sort the directory listing. Any combination of columns from query output can be specified in comma-separated list. You can specify ASC (ascending) or DESC (descending) as qualifiers for column names. ASC is the default | |
| newDirectory | String | No | Required for action = "rename". Ignored by all other actions. The new name of the directory specified in the directory attribute. | |
| recurse | Boolean | No | Whether ColdFusion performs the action on subdirectories |
Example Usage
Using a custom function in a <cfdirectory action="list" />
<cfdirectory action="list" directory="/test/" recurse="true" name="qFiles" filter="#theFilter#" /> <cfdump var="#qFiles#" /> <cffunction name="thefilter" returntype="boolean"> <cfargument name="fullpath" type="string" /> <--- disallow a certain directory ---> <cfif refindNoCase("[/\\]DisallowedDirectory[/\\]", arguments.fullPath)> <cfreturn false /> <--- allow certain extensions ---> <cfelseif refindNoCase("\.(cfm|cfc|txt)$", arguments.fullPath)> <cfreturn true /> <cfelse> <cfreturn false /> </cfif> </cffunction>
SideBar
User Login
Comments (