Uploaded image for project: 'Commons IO'
  1. Commons IO
  2. IO-173

FileUtils.listFiles() doesn't return directories

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.4
    • Fix Version/s: 2.2
    • Component/s: Utilities
    • Labels:
      None

      Description

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

        Attachments

        1. IO-173.patch
          4 kB
          Marcos Vinícius da Silva
        2. IO-173.patch
          10 kB
          Marcos Vinícius da Silva

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              francois.loison François Loison
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: