[ https://issues.apache.org/jira/browse/IO-599?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Gary D. Gregory closed IO-599. ------------------------------ Resolution: Information Provided > RFE: FileUtils.glob[One]([File rootSearchDir, ] String antFileExpr) > ------------------------------------------------------------------- > > Key: IO-599 > URL: https://issues.apache.org/jira/browse/IO-599 > Project: Commons IO > Issue Type: Improvement > Reporter: Mark > Priority: Minor > > Can we please introduce a simpler file search method than the existing ones > that are using filters? > Currently I'm using the ant lib's DirectoryScanner for that purpose. However, > ant comes with quite a few dependencies, introducing unnecessary overhead and > bloat. > Examples: > {code:java} > // select all sub directories (final slash) of cwd > File[] f = FileUtils.glob("**/"); > // select first sub dir, null if there is none > File f = FileUtils.globFirst("**/"); > // exception if there is none > File f = FileUtils.globFirstE("**/"); > // select exactly one sub dir, return null if there are more or less > File f = FileUtils.globOne("**/"); > // select exactly one sub dir, throw exception if there are more or less > File f = FileUtils.globOneE("**/"); > // two parameter version allows to start recursive search in specified dir > File f = FileUtils.globOneE(new File("."), "**/"); > {code} > "\*\*" matches anything including file separators, "\*" matches anything > excluding file separators, a final "/" indicates directory matching, a > missing final slash indicates file matching. The function always traverses > the entire directory hierarchy, starting at cwd by default (not counting > optimizations). The search pattern is standardized, ie. "/" on all platforms, > ie. "/" is not the platform file separator. > Here is an example implementation: > https://github.com/jjYBdx4IL/misc/blob/df9c239c56640f0d3e27d1b5d510b62f5726253f/io-utils/src/test/java/com/github/jjYBdx4IL/utils/io/FindUtilsTest.java#L105 > https://github.com/jjYBdx4IL/misc/blob/df9c239c56640f0d3e27d1b5d510b62f5726253f/io-utils/src/main/java/com/github/jjYBdx4IL/utils/io/FindUtils.java -- This message was sent by Atlassian Jira (v8.20.7#820007)