Example #1
0
  /**
   * Walk behaves more like pyhton's os.walk than the walker I built around it again this was
   * laziness. Is a breadth first search modifications could include max depth
   *
   * @return File[] containing files that fit the filter
   */
  public File[] walk() {
    DirectoryFilter df = new DirectoryFilter();
    Queue<File> dirQueue = new LinkedBlockingQueue<File>();
    dirQueue.addAll(Arrays.asList(m_topLevel.listFiles(df)));
    m_fileStructure.addDirs(m_topLevel.listFiles(df));
    m_fileStructure.addFiles(walkFiles(m_topLevel));

    while (!dirQueue.isEmpty()) {
      File d = dirQueue.poll();
      dirQueue.addAll(Arrays.asList(d.listFiles(df)));
      m_fileStructure.addDirs(d.listFiles(df));
      m_fileStructure.addFiles(walkFiles(d));
    }

    return m_fileStructure.getFiles();
  }
Example #2
0
 public File[] getDirs() {
   return m_fileStructure.getDirs();
 }