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

EmptyFileFilter doesn't work on directories using FileUtils.listFilesAndDirs

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Invalid
    • Affects Version/s: 2.4
    • Fix Version/s: None
    • Component/s: Filters
    • Labels:
      None
    • Environment:

      Distributor ID: Ubuntu
      Description: Ubuntu 12.04.5 LTS
      Release: 12.04
      Codename: precise

      Description

      My directory tree:

      ~/ioutils> ls -lhR
      .:
      total 20K
      drwxrwxr-x 2 jorge jorge 4.0K Dec  2 14:54 empty/
      drwxrwxr-x 2 jorge jorge 4.0K Dec  2 14:54 not-empty/
      -rw-rw-r-- 1 jorge jorge    5 Dec  2 15:02 text.txt
      
      ./empty:
      total 0
      
      ./not-empty:
      total 12K
      -rw-rw-r-- 1 jorge jorge 5 Dec  2 14:54 text.txt
      

      When I execute:

      File baseDir = new File("/home/jorge/ioutils");
      IOFileFilter emptyDirectoriesFilter = FileFilterUtils.and(
        DirectoryFileFilter.DIRECTORY, 
        EmptyFileFilter.EMPTY
      );
      FileUtils.listFilesAndDirs(baseDir, emptyDirectoriesFilter, TrueFileFilter.TRUE);
      

      I obtain:

      [/home/jorge/ioutils, /home/jorge/ioutils/not-empty, /home/jorge/ioutils/empty]
      

      Issue: /home/jorge/ioutils/not-empty directory is included in the result.

      But If I execute

      baseDir.list(emptyDirectoriesFilter);
      

      the correct result includes /home/jorge/empty directory.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              Giorgy Jorge Spinsanti
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: