commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Georg Reichelt (JIRA)" <j...@apache.org>
Subject [jira] [Created] (IO-495) FileUtils.listFilesAndDirs behaves unexpected
Date Thu, 07 Jan 2016 13:29:39 GMT
David Georg Reichelt created IO-495:
---------------------------------------

             Summary: FileUtils.listFilesAndDirs behaves unexpected
                 Key: IO-495
                 URL: https://issues.apache.org/jira/browse/IO-495
             Project: Commons IO
          Issue Type: Improvement
          Components: Utilities
    Affects Versions: 2.4
         Environment: Ubuntu, Java 8
            Reporter: David Georg Reichelt
            Priority: Minor


The behaviour of listFilesAndDirs is quite unexpected in my opinion.

FileUtils.listFiles searches for files in a directory, where the files match the filter, including
the subdirectories which are matched by the dirFilter.
FileUtils.listFilesAndDirs searches for files and directories, where the files match the filter
and the directories match the directory filter, including the subdirectories which are matched
by the dirFilter.

But, if one extends the listFiles-method, the logical behaviour would be:
FileUtils.listFiles searches for files and directories in a directory, where the files and
directories match the filter, including the subdirectories which are matched by the dirFilter.

This method has been discussed in https://issues.apache.org/jira/browse/IO-328, but there
the point was, that listFilesAndDirs also includes the root folder, which was documented correctly
after this bug. In my opinion, the problem not the inclusion of the root filter but the different
behaviour from the listFiles-method. 

I apply an patch, where the method filters everything with the first filter and includes subdirectories
if they are included by the dirFilter. One could also keep the current method, but imho it
then should be named different as it behaves different than listFiles (maybe filterFilesAndDirs?).




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message