commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Fran├žois Loison (JIRA) <j...@apache.org>
Subject [jira] Created: (IO-173) FileUtils.listFiles() doesn't return directories
Date Fri, 06 Jun 2008 11:22:45 GMT
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:

 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]);
                }
            }
        }
    }


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message