DirectoryList
List the contents of a directory.
Returns either an array, or a query depending on the {@code listInfo} argument.
The {@code listInfo} argument can be one of the following:
{@code name} - Returns an array of the names of the items in the directory.
{@code path} - Returns an array of the absolute paths of the items in the directory.
{@code query} - Returns a query of the items in the directory containing the following fields:
{@code attributes} - The attributes of the item (R, W, X, H).
{@code dateLastModified} - The date the item was last modified.
{@code directory} - The directory containing the item.
{@code mode} - The mode of the item.
{@code name} - The name of the item.
{@code size} - The size of the item in bytes.
{@code type} - The type of the item (either "Dir" or "File").
The {@code filter} argument can be the following:
A closure/lambda that takes a single argument (the path of the item) and returns a boolean. True to return it, false otherwise.
A string that is a glob pattern: E.g. ".txt" to only return files with the .txt extension. Or you can use the {@code |} pipe to separate multiple patterns: E.g. ".txt|*.csv" to return files with either the .txt or .csv extension.
Method Signature
Arguments
Argument | Type | Required | Description | Default |
---|---|---|---|---|
|
|
| The absolute path to the directory to list. | |
|
|
| Whether to recurse into subdirectories or not. The default is false. |
|
|
|
| The type of information to return. Valid values are "name", "path", and "query". The default is "path". |
|
|
|
| A filter to apply to the listing. This can be a function that takes a single argument (the path of the item) and returns a boolean or a string that is a glob pattern. The default is no filter. | |
|
|
| The sort order of the listing. Valid values are "name", "size", "date", and "type". The default is "name".You can also use |
|
|
|
| The type of items to list. Valid values are "all", "file", and "dir". Default is "all". |
|
Examples
Related
Last updated