Class DirectoryList
java.lang.Object
ortus.boxlang.runtime.bifs.BIF
ortus.boxlang.runtime.bifs.global.io.DirectoryList
-
Field Summary
Fields inherited from class ortus.boxlang.runtime.bifs.BIF
__functionName, __isMemberExecution, asyncService, cacheService, componentService, declaredArguments, functionService, interceptorService, logger, moduleService, runtime, schedulerService -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription_invoke(IBoxContext context, ArgumentsScope arguments) List the contents of a directory.listingToNames(Stream<Path> listing) listingToPaths(Stream<Path> listing) listingToQuery(Stream<Path> listing, String sort) listingToQueryNames(Stream<Path> listing, Path basePath) Methods inherited from class ortus.boxlang.runtime.bifs.BIF
announce, getDeclaredArguments, invoke
-
Constructor Details
-
DirectoryList
public DirectoryList()Constructor
-
-
Method Details
-
_invoke
List the contents of a directory. Returns either an array, or a query depending on thelistInfoargument.The
listInfoargument can be one of the following:name- Returns an array of the names of the items in the directory.path- Returns an array of the absolute paths of the items in the directory.query- Returns a query of the items in the directory containing the following fields:attributes- The attributes of the item (R, W, X, H).dateLastModified- The date the item was last modified.directory- The directory containing the item.mode- The mode of the item.name- The name of the item.size- The size of the item in bytes.type- The type of the item (either "Dir" or "File").
The
filterargument 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.
DirectoryList( path: "/path/to/dir", filter: path -> path.endsWith(".txt") ) -
A string that is a glob pattern: E.g. "*.txt" to only return files with the .txt extension. Or you can use the
|pipe to separate multiple patterns: E.g. "*.txt|*.csv" to return files with either the .txt or .csv extension.
-
listingToPaths
-
listingToNames
-
listingToQuery
-
listingToQueryNames
-