[
https://issues.apache.org/jira/browse/IO-489?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Sebb resolved IO-489.
---------------------
Resolution: Invalid
The Javadoc for FileUtils.listFilesAndDirs says [1]
{quote}
Parameters:
directory - the directory to search in
fileFilter - filter to apply when finding files.
dirFilter - optional filter to apply when finding subdirectories. If this
parameter is null, subdirectories will not be included in the search. Use
TrueFileFilter.INSTANCE to match all directories.
{quote}
If you want to match only some sub-directories you have to provide the
appropriate filter.
[1]
http://commons.apache.org/proper/commons-io/javadocs/api-2.4/org/apache/commons/io/FileUtils.html#listFilesAndDirs%28java.io.File,%20org.apache.commons.io.filefilter.IOFileFilter,%20org.apache.commons.io.filefilter.IOFileFilter%29
> EmptyFileFilter doesn't work on directories using FileUtils.listFilesAndDirs
> ----------------------------------------------------------------------------
>
> Key: IO-489
> URL: https://issues.apache.org/jira/browse/IO-489
> Project: Commons IO
> Issue Type: Bug
> Components: Filters
> Affects Versions: 2.4
> Environment: Distributor ID: Ubuntu
> Description: Ubuntu 12.04.5 LTS
> Release: 12.04
> Codename: precise
> Reporter: Jorge Spinsanti
>
> My directory tree:
> {code}
> ~/ioutils> ls -lhR
> .:
> total 20K
> drwxrwxr-x 2 jorge jorge 4.0K Dec 2 14:54 empty/
> drwxrwxr-x 2 jorge jorge 4.0K Dec 2 14:54 not-empty/
> -rw-rw-r-- 1 jorge jorge 5 Dec 2 15:02 text.txt
> ./empty:
> total 0
> ./not-empty:
> total 12K
> -rw-rw-r-- 1 jorge jorge 5 Dec 2 14:54 text.txt
> {code}
> When I execute:
> {code}
> File baseDir = new File("/home/jorge/ioutils");
> IOFileFilter emptyDirectoriesFilter = FileFilterUtils.and(
> DirectoryFileFilter.DIRECTORY,
> EmptyFileFilter.EMPTY
> );
> FileUtils.listFilesAndDirs(baseDir, emptyDirectoriesFilter,
> TrueFileFilter.TRUE);
> {code}
> I obtain:
> {code}
> [/home/jorge/ioutils, /home/jorge/ioutils/not-empty,
> /home/jorge/ioutils/empty]
> {code}
> Issue: {{/home/jorge/ioutils/not-empty}} directory is included in the result.
> But If I execute
> {code}
> baseDir.list(emptyDirectoriesFilter);
> {code}
> the correct result includes {{/home/jorge/empty}} directory.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)