View Javadoc

    1   /***
    2    *
    3    */
    4   package net.sourceforge.pmd.cpd;
    5
    6   import net.sourceforge.pmd.SourceFileSelector;
    7
    8   import java.io.File;
    9   import java.io.FilenameFilter;
    10
    11  /***
    12   * Filtering of directories en wanted source files.
    13   */
    14  public class SourceFileOrDirectoryFilter implements FilenameFilter {
    15      private SourceFileSelector fileSelector;
    16
    17      /***
    18       * Public constructor
    19       *
    20       * @param fileSelector the FileSelector that knows what source files to accept
    21       */
    22      public SourceFileOrDirectoryFilter(SourceFileSelector fileSelector) {
    23          this.fileSelector = fileSelector;
    24      }
    25
    26      public boolean accept(File dir, String filename) {
    27          return (fileSelector.isWantedFile(filename) || (new File(dir.getAbsolutePath() + System.getProperty("file.separator") + filename).isDirectory())) && !filename.equals("SCCS");
    28  // Remark: Why not use "new File(dir, filename).isDirectory()" ?
    29      }
    30  }