Pass type to directorylist and cfdirectory filter closure

Description

Sometimes it would be nice to be able to know whether a path is a file or a directory when passing a closure to the filter parameter of the directoryList() function or the cfdirectory tag.

directoryList( path='C:/', filter=function( path, type ){ if( path contains 'foo' && type == 'dir' ) { return true; } return false; } );

Activity

Zac Spitzer 
3 January 2025 at 14:02
(edited)

Turns out this was already implemented, but the documentation wasn’t updated…. https://luceeserver.atlassian.net/browse/LDEV-4393

Only quirk to note is that type argument is either file or directory, whereas query returns file or dir

https://github.com/lucee/Lucee/commit/d15409c19c3f7e01861708edace91fda62b872cd

Zac Spitzer 
19 December 2024 at 20:44

yeah, i’ll have a look into what can I can do

Sean P. Ford 
19 December 2024 at 20:33

Came looking to see if there was a way to filter a directoryList by dateLastModified and found this Issue. Agree with below that being able to filter by any of the columns returned would be most helpful, as I’m trying to get a listing of files in a directory older than 14 days and have to loop through the entire query to do it. Seems like it should be possible to use the filter UDF to do this and passing a struct in addition to the path for compatibility would be the best way to accomplish this.

Michael Born @ Ortus 
22 July 2022 at 13:52

+1. This issue should be marked as incompat, since ACF passes three arguments: path, type, and extension, whereas Lucee only passes the path argument.

Zac Spitzer 
28 October 2019 at 19:11

re performance, I guess Lucee is using apache commons io for this, lucee bundles 2.4 which was released way back in 2012

https://commons.apache.org/proper/commons-io/changes-report.html#a2.4

2.6 requires java 7, so there maybe some performance wins available from simply upgrading?

Fixed

Details

Assignee

Reporter

New Issue warning screen

Before you create a new Issue, please post to the mailing list first https://dev.lucee.org

Once the issue has been verified, one of the Lucee team will ask you to file an issue

Fix versions

Priority

Created 22 March 2017 at 22:03
Updated 3 January 2025 at 14:09
Resolved 3 January 2025 at 14:03