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

DirectoryFileFilter does not work, the AbstractFileFilter bug

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.0
    • 1.1
    • None
    • None
    • Operating System: Windows XP
      Platform: PC

    • 30992

    Description

      Env: Java 1.4.2, commons-io-1.0.jar, Win XP

      The AbstractFileFilter's FilenameFilter's accept(File, String) method
      implementation constructs the fileName/File (it passes to accept(File))
      wrongly - please see below. This causes the DirectoryFileFilter (in example, I
      did not have time to check out the other AbstractFileFilter implementations)
      failure since it's FileFilter implementation receives the incorrect
      filename/File.

      Note I stumbled into this in Win Env. and really don't know how it works in
      other platforms.

      v1.0 code:
      public boolean accept(File dir, String name)

      { String filename = dir.getName() + File.separator + name; return accept(new File(filename)); }

      correct code should be:
      public boolean accept(File dir, String name)

      { String filename = dir.getPath() + File.separator + name; return accept(new File(filename)); }

      Attachments

        Activity

          People

            Unassigned Unassigned
            nperunicic@yahoo.com Nebojsa Perunicic
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: