commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sebb (Resolved) (JIRA)" <j...@apache.org>
Subject [jira] [Resolved] (IO-173) FileUtils.listFiles() doesn't return directories
Date Thu, 01 Mar 2012 17:49:58 GMT

     [ https://issues.apache.org/jira/browse/IO-173?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Sebb resolved IO-173.
---------------------

       Resolution: Fixed
    Fix Version/s: 2.2

Thanks.

Had to fix a bug in the code.
The directory was being added regardless of the includeSubDirectories setting.

Also moved the storage of the starting directory outside the recursive loop as that saves
constant checking if the directory had already been added.
                
> 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
>             Fix For: 2.2
>
>         Attachments: IO-173.patch, IO-173.patch
>
>
> 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.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

Mime
View raw message