protected Set<File> retrieveMatchingFiles(File rootDir,String pattern) throws IOException {
  if (!rootDir.exists()) {
    if (logger.isDebugEnabled()) {
      logger.debug("Skipping [" + rootDir.getAbsolutePath() + "] because it does not exist");
    }
    return Collections.emptySet();
  }
  if (!rootDir.isDirectory()) {
    if (logger.isWarnEnabled()) {
      logger.warn("Skipping [" + rootDir.getAbsolutePath() + "] because it does not denote a directory");
    }
    return Collections.emptySet();
  }
  if (!rootDir.canRead()) {
    if (logger.isWarnEnabled()) {
      logger.warn("Cannot search for matching files underneath directory [" + rootDir.getAbsolutePath() + "] because the application is not allowed to read the directory");
    }
    return Collections.emptySet();
  }
  String fullPattern=StringUtils.replace(rootDir.getAbsolutePath(),File.separator,"/");
  if (!pattern.startsWith("/")) {
    fullPattern+="/";
  }
  fullPattern=fullPattern + StringUtils.replace(pattern,File.separator,"/");
  Set<File> result=new LinkedHashSet<File>(8);
  doRetrieveMatchingFiles(fullPattern,rootDir,result);
  return result;
}

protected Set < File > retrieveMatchingFiles ( File rootDir , String pattern ) throws IOException { if ( ! rootDir . exists ( ) ) { if ( logger . isDebugEnabled ( ) ) { logger . debug ( "Skipping [" + rootDir . getAbsolutePath ( ) + "] because it does not exist" ) ; } return Collections . emptySet ( ) ; } if ( ! rootDir . isDirectory ( ) ) { if ( logger . isWarnEnabled ( ) ) { logger . warn ( "Skipping [" + rootDir . getAbsolutePath ( ) + "] because it does not denote a directory" ) ; } return Collections . emptySet ( ) ; } if ( ! rootDir . canRead ( ) ) { if ( logger . isWarnEnabled ( ) ) { logger . warn ( "Cannot search for matching files underneath directory [" + rootDir . getAbsolutePath ( ) + "] because the application is not allowed to read the directory" ) ; } return Collections . emptySet ( ) ; } String fullPattern = StringUtils . replace ( rootDir . getAbsolutePath ( ) , File . separator , "/" ) ; if ( ! pattern . startsWith ( "/" ) ) { fullPattern += "/" ; } fullPattern = fullPattern + StringUtils . replace ( pattern , File . separator , "/" ) ; Set < File > result = new LinkedHashSet < File > ( 8 ) ; doRetrieveMatchingFiles ( fullPattern , rootDir , result ) ; return result ; }
retrieve files that match the given path pattern , checking the given directory and its subdirectories .
