You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Sebb (JIRA)" <ji...@apache.org> on 2011/04/10 02:29:06 UTC
[jira] [Updated] (IO-173) FileUtils.listFiles() doesn't return
directories
[ https://issues.apache.org/jira/browse/IO-173?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Sebb updated IO-173:
--------------------
Description:
FileUtils.listFiles() returns only files and not directories.
So it can't be used to retrieve sub-directories.
Some fix could be applied:
{code}
private static void innerListFiles(Collection files, File directory,
IOFileFilter filter) {
File[] found = directory.listFiles((FileFilter) filter);
if (found != null) {
for (int i = 0; i < found.length; i++) {
if (found[i].isDirectory()) {
>>> fix
if ( addDirectories ) {
files.add(found[i]);
}
>>> end fix
innerListFiles(files, found[i], filter);
} else {
files.add(found[i]);
}
}
}
}
{code}
was:
FileUtils.listFiles() returns only files and not directories.
So it can't be used to retrieve sub-directories.
Some fix could be applied:
private static void innerListFiles(Collection files, File directory,
IOFileFilter filter) {
File[] found = directory.listFiles((FileFilter) filter);
if (found != null) {
for (int i = 0; i < found.length; i++) {
if (found[i].isDirectory()) {
>>> fix
if ( addDirectories ) {
files.add(found[i]);
}
>>> end fix
innerListFiles(files, found[i], filter);
} else {
files.add(found[i]);
}
}
}
}
Fix Version/s: (was: 3.x)
Fix layout
> FileUtils.listFiles() doesn't return directories
> ------------------------------------------------
>
> Key: IO-173
> URL: https://issues.apache.org/jira/browse/IO-173
> Project: Commons IO
> Issue Type: Improvement
> Components: Utilities
> Affects Versions: 1.4
> Reporter: François Loison
>
> FileUtils.listFiles() returns only files and not directories.
> So it can't be used to retrieve sub-directories.
> Some fix could be applied:
> {code}
> private static void innerListFiles(Collection files, File directory,
> IOFileFilter filter) {
> File[] found = directory.listFiles((FileFilter) filter);
> if (found != null) {
> for (int i = 0; i < found.length; i++) {
> if (found[i].isDirectory()) {
> >>> fix
> if ( addDirectories ) {
> files.add(found[i]);
> }
> >>> end fix
> innerListFiles(files, found[i], filter);
> } else {
> files.add(found[i]);
> }
> }
> }
> }
> {code}
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira