src/main/java/org/jboss/net/protocol/file/FileURLLister.java
private void listFiles(final URL baseUrl, final URLFilter filter, boolean scanNonDottedSubDirs, ArrayList<URL> resultList)
      throws IOException
   {      
      // List the files at the current dir level, using the provided filter
      final File baseDir = new File(baseUrl.getPath());
      String[] filenames = baseDir.list(new FilenameFilter()
      {
         public boolean accept(File dir, String name)
         {
            try
            {
               return filter.accept(baseUrl, name);
            }
            catch (Exception e)
            {
               log.debug("Unexpected exception filtering entry '" + name + "' in directory '" + baseDir + "'", e);
               return true;
            }
         }
      });
      
      if (filenames == null)
      {
         // This happens only when baseDir not a directory (but this is already
         // checked by the caller) or some unknown IOException happens internally
         // (e.g. run out of file descriptors?). Unfortunately the File API
         // doesn't provide a way to know.
         throw new IOException("Could not list directory '" + baseDir + "', reason unknown");
      }      
      else
      {
         String baseUrlString = baseUrl.toString();
         
         for (int i = 0; i < filenames.length; i++)
         {
            String filename = filenames[i];
            
            // Find out if this is a directory
            File file = new File(baseDir, filename);
            boolean isDir = file.isDirectory();
            
            // The subUrl
            URL subUrl = createURL(baseUrlString, filename, isDir);
            
            // If scanning subdirs and we have a directory, not containing a '.' in
            // the name, recurse into it. This is to allow recursing into grouping
            // dirs like ./deploy/jms, ./deploy/management, etc., avoiding
            // at the same time exploded packages, like .sar, .war, etc.
            if (scanNonDottedSubDirs && isDir && (filename.indexOf('.') == -1))
            {
               // recurse into it
               listFiles(subUrl, filter, scanNonDottedSubDirs, resultList);
            }
            else
            {
               // just add to the list
               resultList.add(subUrl);                
            }
         }
      }
   }
private void listFiles(final URL baseUrl, final URLFilter filter, boolean scanNonDottedSubDirs, ArrayList<URL> resultList)
      throws IOException
   {      
      // List the files at the current dir level, using the provided filter
      final File baseDir = new File(baseUrl.getPath());
      String[] filenames = baseDir.list(new FilenameFilter()
      {
         public boolean accept(File dir, String name)
         {
            try
            {
               return filter.accept(baseUrl, name);
            }
            catch (Exception e)
            {
               log.debug("Unexpected exception filtering entry '" + name + "' in directory '" + baseDir + "'", e);
               return true;
            }
         }
      });
      
      if (filenames == null)
      {
         // This happens only when baseDir not a directory (but this is already
         // checked by the caller) or some unknown IOException happens internally
         // (e.g. run out of file descriptors?). Unfortunately the File API
         // doesn't provide a way to know.
         throw new IOException("Could not list directory '" + baseDir + "', reason unknown");
      }      
      else
      {
         String baseUrlString = baseUrl.toString();
         
         for (int i = 0; i < filenames.length; i++)
         {
            String filename = filenames[i];
            
            // Find out if this is a directory
            File file = new File(baseDir, filename);
            boolean isDir = file.isDirectory();
            
            // The subUrl
            URL subUrl = createURL(baseUrlString, filename, isDir);
            
            // If scanning subdirs and we have a directory, not containing a '.' in
            // the name, recurse into it. This is to allow recursing into grouping
            // dirs like ./deploy/jms, ./deploy/management, etc., avoiding
            // at the same time exploded packages, like .sar, .war, etc.
            if (scanNonDottedSubDirs && isDir && (filename.indexOf('.') == -1))
            {
               // recurse into it
               listFiles(subUrl, filter, scanNonDottedSubDirs, resultList);
            }
            else
            {
               // just add to the list
               resultList.add(subUrl);                
            }
         }
      }
   }
private void listFiles ( final URL baseUrl , final URLFilter filter , boolean scanNonDottedSubDirs , ArrayList < URL > resultList ) throws IOException { // List the files at the current dir level, using the provided filter final File baseDir = new File ( baseUrl . getPath ( ) ) ; String [ ] filenames = baseDir . list ( new FilenameFilter ( ) { public boolean accept ( File dir , String name ) { try { return filter . accept ( baseUrl , name ) ; } catch ( Exception e ) { log . debug ( "Unexpected exception filtering entry '" + name + "' in directory '" + baseDir + "'" , e ) ; return true ; } } } ) ; if ( filenames == null ) { // This happens only when baseDir not a directory (but this is already // checked by the caller) or some unknown IOException happens internally // (e.g. run out of file descriptors?). Unfortunately the File API // doesn't provide a way to know. throw new IOException ( "Could not list directory '" + baseDir + "', reason unknown" ) ; } else { String baseUrlString = baseUrl . toString ( ) ; for ( int i = 0 ; i < filenames . length ; i ++ ) { String filename = filenames [ i ] ; // Find out if this is a directory File file = new File ( baseDir , filename ) ; boolean isDir = file . isDirectory ( ) ; // The subUrl URL subUrl = createURL ( baseUrlString , filename , isDir ) ; // If scanning subdirs and we have a directory, not containing a '.' in // the name, recurse into it. This is to allow recursing into grouping // dirs like ./deploy/jms, ./deploy/management, etc., avoiding // at the same time exploded packages, like .sar, .war, etc. if ( scanNonDottedSubDirs && isDir && ( filename . indexOf ( ' ' ) == - 1 ) ) { // recurse into it listFiles ( subUrl , filter , scanNonDottedSubDirs , resultList ) ; } else { // just add to the list resultList . add ( subUrl ) ; } } } }
Starting from baseUrl, that should point to a directory, populate the
resultList with the contents that pass the filter (in the form of URLs)
and possibly recurse into subdris not containing a '.' in their name.
Starting from baseUrl that should point to a directory populate the resultList with the contents that pass the filter ( in the form of URLs ) and possibly recurse into subdris not containing a . in their name .